comparison base/Exceptions.h @ 130:b290c43f01ec

* Exceptions for file read etc
author Chris Cannam
date Wed, 28 Jun 2006 15:42:04 +0000
parents
children 7aa1de571880
comparison
equal deleted inserted replaced
129:4e38a29c13fc 130:b290c43f01ec
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 #ifndef _EXCEPTIONS_H_
17 #define _EXCEPTIONS_H_
18
19 #include <exception>
20
21 #include <QString>
22
23 class FileNotFound : virtual public std::exception
24 {
25 public:
26 FileNotFound(QString file) throw();
27 virtual ~FileNotFound() throw() { }
28 virtual const char *what() const throw();
29
30 protected:
31 QString m_file;
32 };
33
34 class FailedToOpenFile : virtual public std::exception
35 {
36 public:
37 FailedToOpenFile(QString file) throw();
38 virtual ~FailedToOpenFile() throw() { }
39 virtual const char *what() const throw();
40
41 protected:
42 QString m_file;
43 };
44
45 class DirectoryCreationFailed : virtual public std::exception
46 {
47 public:
48 DirectoryCreationFailed(QString directory) throw();
49 virtual ~DirectoryCreationFailed() throw() { }
50 virtual const char *what() const throw();
51
52 protected:
53 QString m_directory;
54 };
55
56 class FileReadFailed : virtual public std::exception
57 {
58 public:
59 FileReadFailed(QString file) throw();
60 virtual ~FileReadFailed() throw() { }
61 virtual const char *what() const throw();
62
63 protected:
64 QString m_file;
65 };
66
67 class FileOperationFailed : virtual public std::exception
68 {
69 public:
70 FileOperationFailed(QString file, QString operation) throw();
71 virtual ~FileOperationFailed() throw() { }
72 virtual const char *what() const throw();
73
74 protected:
75 QString m_file;
76 QString m_operation;
77 };
78
79 class InsufficientDiscSpace : virtual public std::exception
80 {
81 public:
82 InsufficientDiscSpace(QString directory,
83 size_t required, size_t available) throw();
84 virtual ~InsufficientDiscSpace() throw() { }
85 virtual const char *what() const throw();
86
87 size_t getRequired() const { return m_required; }
88 size_t getAvailable() const { return m_available; }
89
90 protected:
91 QString m_directory;
92 size_t m_required;
93 size_t m_available;
94 };
95
96 #endif