-
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
Sep 3, 2021
1 parent
f5f3937
commit 79cba70
Showing
6 changed files
with
149 additions
and
48 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,83 @@ | ||
#pragma once | ||
|
||
#include <exception> | ||
#include <sstream> | ||
#include <string> | ||
|
||
namespace openpower | ||
{ | ||
namespace guard | ||
{ | ||
namespace exception | ||
{ | ||
// TODO:Issue #3325, to avoid multiple exception classes | ||
class GuardException : public std::exception | ||
{ | ||
public: | ||
explicit GuardException(const std::string& message) : message(message){}; | ||
|
||
const char* what() const noexcept override | ||
{ | ||
return message.c_str(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
class GuardFileOpenFailed : public GuardException | ||
{ | ||
public: | ||
explicit GuardFileOpenFailed(const std::string& msg) : | ||
GuardException(msg){}; | ||
}; | ||
|
||
class GuardFileReadFailed : public GuardException | ||
{ | ||
public: | ||
explicit GuardFileReadFailed(const std::string& msg) : | ||
GuardException(msg){}; | ||
}; | ||
|
||
class GuardFileWriteFailed : public GuardException | ||
{ | ||
public: | ||
explicit GuardFileWriteFailed(const std::string& msg) : | ||
GuardException(msg){}; | ||
}; | ||
|
||
class GuardFileSeekFailed : public GuardException | ||
{ | ||
public: | ||
explicit GuardFileSeekFailed(const std::string& msg) : | ||
GuardException(msg){}; | ||
}; | ||
|
||
class InvalidEntry : public GuardException | ||
{ | ||
public: | ||
explicit InvalidEntry(const std::string& msg) : GuardException(msg){}; | ||
}; | ||
|
||
class AlreadyGuarded : public GuardException | ||
{ | ||
public: | ||
explicit AlreadyGuarded(const std::string& msg) : GuardException(msg){}; | ||
}; | ||
|
||
class InvalidEntityPath : public GuardException | ||
{ | ||
public: | ||
explicit InvalidEntityPath(const std::string& msg) : GuardException(msg){}; | ||
}; | ||
|
||
class GuardFileOverFlowed : public GuardException | ||
{ | ||
public: | ||
explicit GuardFileOverFlowed(const std::string& msg) : | ||
GuardException(msg){}; | ||
}; | ||
|
||
} // 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
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
Oops, something went wrong.