svcore  1.9
Exceptions.cpp
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include "Exceptions.h"
00017 
00018 #include <iostream>
00019 
00020 #include "Debug.h"
00021 
00022 FileNotFound::FileNotFound(QString file) throw() :
00023     m_file(file)
00024 {
00025     cerr << "ERROR: File not found: "
00026               << file << endl;
00027 }
00028 
00029 const char *
00030 FileNotFound::what() const throw()
00031 {
00032     return QString("File \"%1\" not found")
00033         .arg(m_file).toLocal8Bit().data();
00034 }
00035 
00036 FailedToOpenFile::FailedToOpenFile(QString file) throw() :
00037     m_file(file)
00038 {
00039     cerr << "ERROR: Failed to open file: "
00040               << file << endl;
00041 }
00042 
00043 const char *
00044 FailedToOpenFile::what() const throw()
00045 {
00046     return QString("Failed to open file \"%1\"")
00047         .arg(m_file).toLocal8Bit().data();
00048 }
00049 
00050 DirectoryCreationFailed::DirectoryCreationFailed(QString directory) throw() :
00051     m_directory(directory)
00052 {
00053     cerr << "ERROR: Directory creation failed for directory: "
00054               << directory << endl;
00055 }
00056 
00057 const char *
00058 DirectoryCreationFailed::what() const throw()
00059 {
00060     return QString("Directory creation failed for \"%1\"")
00061         .arg(m_directory).toLocal8Bit().data();
00062 }
00063 
00064 FileReadFailed::FileReadFailed(QString file) throw() :
00065     m_file(file)
00066 {
00067     cerr << "ERROR: File read failed for file: "
00068               << file << endl;
00069 }
00070 
00071 const char *
00072 FileReadFailed::what() const throw()
00073 {
00074     return QString("File read failed for \"%1\"")
00075         .arg(m_file).toLocal8Bit().data();
00076 }
00077 
00078 FileOperationFailed::FileOperationFailed(QString file, QString op) throw() :
00079     m_file(file),
00080     m_operation(op)
00081 {
00082     cerr << "ERROR: File " << op << " failed for file: "
00083               << file << endl;
00084 }
00085 
00086 const char *
00087 FileOperationFailed::what() const throw()
00088 {
00089     return QString("File %1 failed for \"%2\"")
00090         .arg(m_operation).arg(m_file).toLocal8Bit().data();
00091 }
00092 
00093 InsufficientDiscSpace::InsufficientDiscSpace(QString directory,
00094                                              int required,
00095                                              int available) throw() :
00096     m_directory(directory),
00097     m_required(required),
00098     m_available(available)
00099 {
00100     cerr << "ERROR: Not enough disc space available in "
00101               << directory << ": need " << required
00102               << ", only have " << available << endl;
00103 }
00104 
00105 InsufficientDiscSpace::InsufficientDiscSpace(QString directory) throw() :
00106     m_directory(directory),
00107     m_required(0),
00108     m_available(0)
00109 {
00110     cerr << "ERROR: Not enough disc space available in "
00111               << directory << endl;
00112 }
00113 
00114 const char *
00115 InsufficientDiscSpace::what() const throw()
00116 {
00117     if (m_required > 0) {
00118         return QString("Not enough space available in \"%1\": need %2, have %3")
00119             .arg(m_directory).arg(m_required).arg(m_available).toLocal8Bit().data();
00120     } else {
00121         return QString("Not enough space available in \"%1\"")
00122             .arg(m_directory).toLocal8Bit().data();
00123     }
00124 }
00125 
00126 AllocationFailed::AllocationFailed(QString purpose) throw() :
00127     m_purpose(purpose)
00128 {
00129     cerr << "ERROR: Allocation failed: " << purpose
00130               << endl;
00131 }
00132 
00133 const char *
00134 AllocationFailed::what() const throw()
00135 {
00136     return QString("Allocation failed: %1")
00137         .arg(m_purpose).toLocal8Bit().data();
00138 }
00139 
00140