svcore  1.9
Exceptions.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "Exceptions.h"
17 
18 #include <iostream>
19 
20 #include "Debug.h"
21 
22 FileNotFound::FileNotFound(QString file) throw() :
23  m_file(file)
24 {
25  cerr << "ERROR: File not found: "
26  << file << endl;
27 }
28 
29 const char *
30 FileNotFound::what() const throw()
31 {
32  return QString("File \"%1\" not found")
33  .arg(m_file).toLocal8Bit().data();
34 }
35 
36 FailedToOpenFile::FailedToOpenFile(QString file) throw() :
37  m_file(file)
38 {
39  cerr << "ERROR: Failed to open file: "
40  << file << endl;
41 }
42 
43 const char *
44 FailedToOpenFile::what() const throw()
45 {
46  return QString("Failed to open file \"%1\"")
47  .arg(m_file).toLocal8Bit().data();
48 }
49 
51  m_directory(directory)
52 {
53  cerr << "ERROR: Directory creation failed for directory: "
54  << directory << endl;
55 }
56 
57 const char *
59 {
60  return QString("Directory creation failed for \"%1\"")
61  .arg(m_directory).toLocal8Bit().data();
62 }
63 
64 FileReadFailed::FileReadFailed(QString file) throw() :
65  m_file(file)
66 {
67  cerr << "ERROR: File read failed for file: "
68  << file << endl;
69 }
70 
71 const char *
72 FileReadFailed::what() const throw()
73 {
74  return QString("File read failed for \"%1\"")
75  .arg(m_file).toLocal8Bit().data();
76 }
77 
78 FileOperationFailed::FileOperationFailed(QString file, QString op) throw() :
79  m_file(file),
80  m_operation(op)
81 {
82  cerr << "ERROR: File " << op << " failed for file: "
83  << file << endl;
84 }
85 
86 const char *
88 {
89  return QString("File %1 failed for \"%2\"")
90  .arg(m_operation).arg(m_file).toLocal8Bit().data();
91 }
92 
94  int required,
95  int available) throw() :
96  m_directory(directory),
97  m_required(required),
98  m_available(available)
99 {
100  cerr << "ERROR: Not enough disc space available in "
101  << directory << ": need " << required
102  << ", only have " << available << endl;
103 }
104 
106  m_directory(directory),
107  m_required(0),
108  m_available(0)
109 {
110  cerr << "ERROR: Not enough disc space available in "
111  << directory << endl;
112 }
113 
114 const char *
116 {
117  if (m_required > 0) {
118  return QString("Not enough space available in \"%1\": need %2, have %3")
119  .arg(m_directory).arg(m_required).arg(m_available).toLocal8Bit().data();
120  } else {
121  return QString("Not enough space available in \"%1\"")
122  .arg(m_directory).toLocal8Bit().data();
123  }
124 }
125 
126 AllocationFailed::AllocationFailed(QString purpose) throw() :
127  m_purpose(purpose)
128 {
129  cerr << "ERROR: Allocation failed: " << purpose
130  << endl;
131 }
132 
133 const char *
134 AllocationFailed::what() const throw()
135 {
136  return QString("Allocation failed: %1")
137  .arg(m_purpose).toLocal8Bit().data();
138 }
139 
140 
virtual const char * what() const
Definition: Exceptions.cpp:115
FileNotFound(QString file)
Definition: Exceptions.cpp:22
QString m_purpose
Definition: Exceptions.h:108
FileOperationFailed(QString file, QString operation)
Definition: Exceptions.cpp:78
FailedToOpenFile(QString file)
Definition: Exceptions.cpp:36
virtual const char * what() const
Definition: Exceptions.cpp:72
QString m_file
Definition: Exceptions.h:33
DirectoryCreationFailed(QString directory)
Definition: Exceptions.cpp:50
virtual const char * what() const
Definition: Exceptions.cpp:134
virtual const char * what() const
Definition: Exceptions.cpp:58
virtual const char * what() const
Definition: Exceptions.cpp:87
virtual const char * what() const
Definition: Exceptions.cpp:44
QString m_file
Definition: Exceptions.h:44
AllocationFailed(QString purpose)
Definition: Exceptions.cpp:126
InsufficientDiscSpace(QString directory, int required, int available)
Definition: Exceptions.cpp:93
FileReadFailed(QString file)
Definition: Exceptions.cpp:64
QString m_file
Definition: Exceptions.h:66
virtual const char * what() const
Definition: Exceptions.cpp:30