-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new exception when file not found
- Loading branch information
1 parent
7ef3693
commit 427a155
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <exception> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
class NoSuchFileException : public std::exception { | ||
|
||
public: | ||
|
||
NoSuchFileException(string filepath) : filepath(filepath) { | ||
std::string errType = "Unable to find file "; | ||
errMsg = (errType + filepath).c_str(); | ||
}; | ||
|
||
const char* what() const noexcept { | ||
return errMsg; | ||
} | ||
|
||
private: | ||
std::string filepath; | ||
const char* errMsg; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters