forked from y-scope/clp
-
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.
feat(ffi): Add initial implementation of
IrErrorCode
(using the `Er…
…rorCode` template) which will replace the `IRErrorCode` enum. (y-scope#623)
- Loading branch information
1 parent
2160362
commit 7176c5e
Showing
4 changed files
with
67 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,26 @@ | ||
#include "IrErrorCode.hpp" | ||
|
||
#include <string> | ||
|
||
using IrErrorCategory = clp::error_handling::ErrorCategory<clp::ffi::ir_stream::IrErrorCodeEnum>; | ||
using clp::ffi::ir_stream::IrErrorCodeEnum; | ||
|
||
template <> | ||
auto IrErrorCategory::name() const noexcept -> char const* { | ||
return "clp::ffi::ir_stream::IrErrorCode"; | ||
} | ||
|
||
template <> | ||
auto IrErrorCategory::message(IrErrorCodeEnum error_enum) const -> std::string { | ||
switch (error_enum) { | ||
case IrErrorCodeEnum::DecodingMethodFailure: | ||
return "The decoding method failed."; | ||
case IrErrorCodeEnum::EndOfStream: | ||
return "The end-of-stream IR unit has already been consumed."; | ||
case IrErrorCodeEnum::IncompleteStream: | ||
return "The IR stream ended with a truncated IR unit or did not terminate with an " | ||
"end-of-stream IR unit."; | ||
default: | ||
return "Unknown error code enum."; | ||
} | ||
} |
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,24 @@ | ||
#ifndef CLP_IRERRORCODE_HPP | ||
#define CLP_IRERRORCODE_HPP | ||
|
||
#include <cstdint> | ||
|
||
#include "../../error_handling/ErrorCode.hpp" | ||
|
||
namespace clp::ffi::ir_stream { | ||
/** | ||
* This enum class represents all possible error codes related to serializing or deserializing CLP | ||
* IR streams. | ||
*/ | ||
enum class IrErrorCodeEnum : uint8_t { | ||
DecodingMethodFailure, | ||
EndOfStream, | ||
IncompleteStream, | ||
}; | ||
|
||
using IrErrorCode = clp::error_handling::ErrorCode<IrErrorCodeEnum>; | ||
} // namespace clp::ffi::ir_stream | ||
|
||
CLP_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(clp::ffi::ir_stream::IrErrorCodeEnum); | ||
|
||
#endif // CLP_IRERRORCODE_HPP |
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