-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libguard: Adding user defined exceptions
Changes: -Adding user defined exceptions in libguard so that the caller can distinguish the type of error at his end. -Changes in respective UTs. Test: Created guard record, tried creating the same. Deleting a non guarded record. Ran UTs in docker env. Signed-off-by: Chirag Sharma <[email protected]>
- Loading branch information
Chirag Sharma
committed
Aug 17, 2021
1 parent
8965dbb
commit e23e7df
Showing
6 changed files
with
212 additions
and
51 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,141 @@ | ||
#pragma once | ||
|
||
#include <exception> | ||
#include <string> | ||
|
||
namespace openpower | ||
{ | ||
namespace guard | ||
{ | ||
namespace exception | ||
{ | ||
class GuardFileOpenFailed : public std::exception | ||
{ | ||
public: | ||
explicit GuardFileOpenFailed(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class GuardFileReadFailed : public std::exception | ||
{ | ||
public: | ||
explicit GuardFileReadFailed(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class GuardFileWriteFailed : public std::exception | ||
{ | ||
public: | ||
explicit GuardFileWriteFailed(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class GuardFileSeekFailed : public std::exception | ||
{ | ||
public: | ||
explicit GuardFileSeekFailed(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class InvalidEntityPath : public std::exception | ||
{ | ||
public: | ||
explicit InvalidEntityPath(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class InvalidEntry : public std::exception | ||
{ | ||
public: | ||
explicit InvalidEntry(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class AlreadyGuarded : public std::exception | ||
{ | ||
public: | ||
explicit AlreadyGuarded(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class GuardFileOverFlowed : public std::exception | ||
{ | ||
public: | ||
explicit GuardFileOverFlowed(const std::string& message) : message(message) | ||
{ | ||
} | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
} // namespace exception | ||
} // namespace guard | ||
} // namespace openpower |
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
Oops, something went wrong.