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 <iostream>
Chris@130: 
Chris@130: FileNotFound::FileNotFound(QString file) throw() :
Chris@130:     m_file(file)
Chris@130: {
Chris@130:     std::cerr << "ERROR: File not found: "
Chris@130:               << file.toStdString() << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: FileNotFound::what() const throw()
Chris@130: {
Chris@130:     return QString("File \"%1\" not found")
Chris@130:         .arg(m_file).toLocal8Bit().data();
Chris@130: }
Chris@130: 
Chris@130: FailedToOpenFile::FailedToOpenFile(QString file) throw() :
Chris@130:     m_file(file)
Chris@130: {
Chris@130:     std::cerr << "ERROR: Failed to open file: "
Chris@130:               << file.toStdString() << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: FailedToOpenFile::what() const throw()
Chris@130: {
Chris@130:     return QString("Failed to open file \"%1\"")
Chris@130:         .arg(m_file).toLocal8Bit().data();
Chris@130: }
Chris@130: 
Chris@130: DirectoryCreationFailed::DirectoryCreationFailed(QString directory) throw() :
Chris@130:     m_directory(directory)
Chris@130: {
Chris@130:     std::cerr << "ERROR: Directory creation failed for directory: "
Chris@130:               << directory.toStdString() << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: DirectoryCreationFailed::what() const throw()
Chris@130: {
Chris@130:     return QString("Directory creation failed for \"%1\"")
Chris@130:         .arg(m_directory).toLocal8Bit().data();
Chris@130: }
Chris@130: 
Chris@130: FileReadFailed::FileReadFailed(QString file) throw() :
Chris@130:     m_file(file)
Chris@130: {
Chris@130:     std::cerr << "ERROR: File read failed for file: "
Chris@130:               << file.toStdString() << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: FileReadFailed::what() const throw()
Chris@130: {
Chris@130:     return QString("File read failed for \"%1\"")
Chris@130:         .arg(m_file).toLocal8Bit().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@130:     std::cerr << "ERROR: File " << op.toStdString() << " failed for file: "
Chris@130:               << file.toStdString() << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: FileOperationFailed::what() const throw()
Chris@130: {
Chris@130:     return QString("File %1 failed for \"%2\"")
Chris@130:         .arg(m_operation).arg(m_file).toLocal8Bit().data();
Chris@130: }
Chris@130: 
Chris@130: InsufficientDiscSpace::InsufficientDiscSpace(QString directory,
Chris@130:                                              size_t required,
Chris@130:                                              size_t available) throw() :
Chris@130:     m_directory(directory),
Chris@130:     m_required(required),
Chris@130:     m_available(available)
Chris@130: {
Chris@130:     std::cerr << "ERROR: Not enough disc space available in "
Chris@130:               << directory.toStdString() << ": need " << required
Chris@130:               << ", only have " << available << std::endl;
Chris@130: }
Chris@130: 
Chris@130: const char *
Chris@130: InsufficientDiscSpace::what() const throw()
Chris@130: {
Chris@130:     return QString("Not enough space available in \"%1\": need %2, have %3")
Chris@130:         .arg(m_directory).arg(m_required).arg(m_available).toLocal8Bit().data();
Chris@130: }
Chris@130: 
Chris@387: AllocationFailed::AllocationFailed(QString purpose) throw() :
Chris@387:     m_purpose(purpose)
Chris@387: {
Chris@387:     std::cerr << "ERROR: Allocation failed: " << purpose.toStdString()
Chris@387:               << std::endl;
Chris@387: }
Chris@387: 
Chris@387: const char *
Chris@387: AllocationFailed::what() const throw()
Chris@387: {
Chris@387:     return QString("Allocation failed: %1")
Chris@387:         .arg(m_purpose).toLocal8Bit().data();
Chris@387: }
Chris@387: 
Chris@387: