Chris@130: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@130: Chris@130: /* Chris@130: Sonic Visualiser Chris@130: An audio file viewer and annotation editor. Chris@130: Centre for Digital Music, Queen Mary, University of London. Chris@130: This file copyright 2006 Chris Cannam. Chris@130: Chris@130: This program is free software; you can redistribute it and/or Chris@130: modify it under the terms of the GNU General Public License as Chris@130: published by the Free Software Foundation; either version 2 of the Chris@130: License, or (at your option) any later version. See the file Chris@130: COPYING included with this distribution for more information. Chris@130: */ Chris@130: Chris@130: #include "Exceptions.h" Chris@130: Chris@130: #include Chris@130: Chris@843: #include "Debug.h" Chris@843: Chris@130: FileNotFound::FileNotFound(QString file) throw() : Chris@130: m_file(file) Chris@130: { Chris@1848: cerr << "ERROR: File not found: " << file << endl; Chris@130: } Chris@130: Chris@130: const char * Chris@130: FileNotFound::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("File \"%1\" not found").arg(m_file).toLocal8Bit(); Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@130: FailedToOpenFile::FailedToOpenFile(QString file) throw() : Chris@130: m_file(file) Chris@130: { Chris@843: cerr << "ERROR: Failed to open file: " Chris@843: << file << endl; Chris@130: } Chris@130: Chris@130: const char * Chris@130: FailedToOpenFile::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("Failed to open file \"%1\"").arg(m_file).toLocal8Bit(); Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@130: DirectoryCreationFailed::DirectoryCreationFailed(QString directory) throw() : Chris@130: m_directory(directory) Chris@130: { Chris@843: cerr << "ERROR: Directory creation failed for directory: " Chris@1848: << directory << endl; Chris@130: } Chris@130: Chris@130: const char * Chris@130: DirectoryCreationFailed::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("Directory creation failed for \"%1\"").arg(m_directory) Chris@1848: .toLocal8Bit(); Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@130: FileReadFailed::FileReadFailed(QString file) throw() : Chris@130: m_file(file) Chris@130: { Chris@1848: cerr << "ERROR: File read failed for file: " << file << endl; Chris@130: } Chris@130: Chris@130: const char * Chris@130: FileReadFailed::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("File read failed for \"%1\"").arg(m_file).toLocal8Bit(); Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@130: FileOperationFailed::FileOperationFailed(QString file, QString op) throw() : Chris@130: m_file(file), Chris@130: m_operation(op) Chris@130: { Chris@1848: cerr << "ERROR: File " << op << " failed for file: " << file << endl; Chris@130: } Chris@130: Chris@130: const char * Chris@130: FileOperationFailed::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("File %1 failed for \"%2\"").arg(m_operation).arg(m_file) Chris@1848: .toLocal8Bit(); Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@130: InsufficientDiscSpace::InsufficientDiscSpace(QString directory, Chris@1038: size_t required, Chris@1038: size_t available) throw() : Chris@130: m_directory(directory), Chris@130: m_required(required), Chris@130: m_available(available) Chris@130: { Chris@843: cerr << "ERROR: Not enough disc space available in " Chris@1848: << directory << ": need " << required Chris@1848: << ", only have " << available << endl; Chris@130: } Chris@130: Chris@544: InsufficientDiscSpace::InsufficientDiscSpace(QString directory) throw() : Chris@544: m_directory(directory), Chris@544: m_required(0), Chris@544: m_available(0) Chris@544: { Chris@1848: cerr << "ERROR: Not enough disc space available in " << directory << endl; Chris@544: } Chris@544: Chris@130: const char * Chris@130: InsufficientDiscSpace::what() const throw() Chris@130: { Chris@1848: static QByteArray msg; Chris@544: if (m_required > 0) { Chris@1848: msg = QString("Not enough space available in \"%1\": need %2, have %3") Chris@1848: .arg(m_directory).arg(m_required).arg(m_available).toLocal8Bit(); Chris@544: } else { Chris@1848: msg = QString("Not enough space available in \"%1\"") Chris@1848: .arg(m_directory).toLocal8Bit(); Chris@544: } Chris@1848: return msg.data(); Chris@130: } Chris@130: Chris@387: AllocationFailed::AllocationFailed(QString purpose) throw() : Chris@387: m_purpose(purpose) Chris@387: { Chris@1848: cerr << "ERROR: Allocation failed: " << purpose << endl; Chris@387: } Chris@387: Chris@387: const char * Chris@387: AllocationFailed::what() const throw() Chris@387: { Chris@1848: static QByteArray msg; Chris@1848: msg = QString("Allocation failed: %1").arg(m_purpose).toLocal8Bit(); Chris@1848: return msg.data(); Chris@387: } Chris@387: Chris@387: