ResourceExceptions.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_EXCEPTION__RESOURCE_EXCEPTIONS
18 #define COM_BORA_SOFTWARE__BALAU_EXCEPTION__RESOURCE_EXCEPTIONS
19 
21 #include <Balau/Resource/File.hpp>
22 
23 namespace Balau::Exception {
24 
29  protected: ResourceException(const char * file,
30  int line,
31  const std::string & st,
32  const std::string & name,
33  const std::string & text)
34  : BalauException(file, line, st, name, text) {}
35 };
36 
41  public: InvalidUriException(const char * file, int line, const std::string & st, const std::string & text)
42  : ResourceException(file, line, st, "InvalidUri", text) {}
43 };
44 
49  public: NotFoundException(const char * file, int line, const std::string & st, const std::string & text)
50  : ResourceException(file, line, st, "NotFound", text) {}
51 
52  protected: NotFoundException(const char * file,
53  int line,
54  const std::string & st,
55  const std::string & name,
56  const std::string & text)
57  : ResourceException(file, line, st, name, text) {}
58 };
59 
64  public: const Resource::File file;
65 
66  public: FileNotFoundException(const char * file, int line, const std::string & st, const Resource::File & file_)
67  : NotFoundException(file, line, st, "FileNotFound", file_.toRawString())
68  , file(file_) {}
69 };
70 
71 inline bool operator == (const FileNotFoundException & lhs, const FileNotFoundException & rhs) {
72  return lhs.message == rhs.message && lhs.file == rhs.file;
73 }
74 
79  public: const Resource::File file;
80 
81  public: CouldNotOpenException(const char * file, int line, const std::string & st, const Resource::File & file_)
82  : ResourceException(file, line, st, "CouldNotOpen", file_.toRawString())
83  , file(file_) {}
84 
85  public: CouldNotOpenException(const char * file,
86  int line,
87  const std::string & st,
88  const std::string & message_,
89  const Resource::File & file_)
90  : ResourceException(file, line, st, "CouldNotOpen", message_ + " - " + file_.toRawString())
91  , file(file_) {}
92 };
93 
94 inline bool operator == (const CouldNotOpenException & lhs, const CouldNotOpenException & rhs) {
95  return lhs.message == rhs.message && lhs.file == rhs.file;
96 }
97 
102  public: const Resource::File file;
103 
104  public: CouldNotCreateException(const char * file, int line, const std::string & st, const Resource::File & file_)
105  : ResourceException(file, line, st, "CouldNotCreate", file_.toRawString())
106  , file(file_) {}
107 
108  public: CouldNotCreateException(const char * file,
109  int line,
110  const std::string & st,
111  const std::string & message_,
112  const Resource::File & file_)
113  : ResourceException(file, line, st, "CouldNotCreate", message_ + " - " + file_.toRawString())
114  , file(file_) {}
115 };
116 
117 inline bool operator == (const CouldNotCreateException & lhs, const CouldNotCreateException & rhs) {
118  return lhs.message == rhs.message && lhs.file == rhs.file;
119 }
120 
125  public: const Resource::File file;
126 
127  public: ZipException(const char * file, int line, const std::string & st, const Resource::File & file_)
128  : ResourceException(file, line, st, "Zip", file_.toRawString())
129  , file(file_) {}
130 
131  public: ZipException(const char * file,
132  int line,
133  const std::string & st,
134  const std::string & message_,
135  const Resource::File & file_)
136  : ResourceException(file, line, st, "Zip", message_ + " - " + file_.toRawString())
137  , file(file_) {}
138 };
139 
140 inline bool operator == (const ZipException & lhs, const ZipException & rhs) {
141  return lhs.message == rhs.message && lhs.file == rhs.file;
142 }
143 
144 } // namespace Balau::Exception
145 
146 #endif // COM_BORA_SOFTWARE__BALAU_EXCEPTION__RESOURCE_EXCEPTIONS
bool operator==(const BalauException &lhs, const BalauException &rhs)
Base class comparison function for Balau exceptions.
Definition: BalauException.hpp:112
All exception classes.
Definition: BalauException.hpp:50
A file on the local file system.
Thrown when a resource could not be created.
Definition: ResourceExceptions.hpp:101
Thrown when a zip resource has an error.
Definition: ResourceExceptions.hpp:124
Thrown when a URI is invalid.
Definition: ResourceExceptions.hpp:40
Abstract base class of resource classes.
Definition: ResourceExceptions.hpp:28
Thrown when a resource could not be opened.
Definition: ResourceExceptions.hpp:78
const std::string message
The message.
Definition: BalauException.hpp:59
Thrown when a resource is not found.
Definition: ResourceExceptions.hpp:48
A file on the local file system.
Definition: File.hpp:35
Base Balau exception classes.
Thrown when a resource is not found.
Definition: ResourceExceptions.hpp:63
std::string toRawString() const override
Get a string representing the raw URI.
Definition: File.hpp:572
Base class of all Balau exceptions.
Definition: BalauException.hpp:55