status.h#
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace Common#
Enums
-
enum class StatusCategory : std::uint8_t#
Identifies the subsystem that generated a non-OK
Status.Each enumerator corresponds to a distinct functional area of the ONNX library so that error handlers can quickly determine the origin of a failure without parsing the error message.
Values:
-
enumerator NONE#
No category; used by OK (success) statuses.
-
enumerator CHECKER#
Error originated in the model checker.
-
enumerator OPTIMIZER#
Error originated in the optimizer.
-
enumerator NONE#
-
enum class StatusCode : std::uint8_t#
Distinguishes the type of error carried by a non-OK
Status.Values:
-
enumerator OK#
Operation completed successfully.
-
enumerator FAIL#
Generic, unclassified failure.
-
enumerator INVALID_ARGUMENT#
A caller-supplied argument was invalid.
-
enumerator INVALID_PROTOBUF#
The serialized protobuf data was malformed or otherwise unreadable.
-
enumerator OK#
Functions
-
inline std::ostream &operator<<(std::ostream &out, const Status &status)#
Streams a human-readable representation of
statustoout.Equivalent to writing
status.ToString()to the stream.- Parameters:
out – Destination output stream.
status – Status value to write.
- Returns:
Reference to
outto allow chaining.
-
class Status#
- #include <status.h>
Represents the outcome of an operation.
A default-constructed (or
OK()-returned)Statusrepresents success and holds no heap allocation. Any non-OK status stores aStatusCategory, aStatusCode, and an optional human-readable error message via a heap-allocatedStateobject.- Usage example
using namespace ONNX_LIGHT_NAMESPACE::Common; Status ok; // success assert(ok.IsOK()); Status err{StatusCategory::CHECKER, StatusCode::FAIL, "bad model"}; assert(!err.IsOK()); std::cout << err.ToString(); // "CHECKER:1:bad model"
Public Functions
-
Status() noexcept = default#
Constructs a success (OK) status.
The resulting object has no heap allocation;
IsOK()returnstrue.
-
Status(StatusCategory category, StatusCode code, const std::string &msg)#
Constructs a non-OK status with a category, code, and message.
- Parameters:
category – Subsystem that generated the error.
code – Error code; must not be
StatusCode::OK(asserted in debug builds).msg – Human-readable description of the error.
-
Status(StatusCategory category, StatusCode code)#
Constructs a non-OK status with a category and code but no message.
- Parameters:
category – Subsystem that generated the error.
code – Error code; must not be
StatusCode::OK(asserted in debug builds).
-
inline Status(const Status &other)#
Copy-constructs a
Statusfrom another.- Parameters:
other – Source status to copy.
-
inline Status &operator=(const Status &other)#
Copy-assigns a
Statusfrom another.Performs a deep copy of the internal
Statewhenotheris non-OK. Self-assignment is handled safely.- Parameters:
other – Source status to copy.
- Returns:
Reference to
*this.
-
bool IsOK() const noexcept#
Returns
trueif the status represents success.An OK status has no heap-allocated state; this check is therefore equivalent to testing whether the internal pointer is null.
-
StatusCode Code() const noexcept#
Returns the status code.
Returns
StatusCode::OKwhenIsOK()istrue.
-
StatusCategory Category() const noexcept#
Returns the status category.
Returns
StatusCategory::NONEwhenIsOK()istrue.
-
const std::string &ErrorMessage() const#
Returns the human-readable error message.
Returns a reference to an empty string when
IsOK()istrueor when no message was supplied to the constructor.
-
std::string ToString() const#
Returns a human-readable string representation of the status.
For OK statuses returns
"OK". For non-OK statuses the format is"[CategoryError] : <code> : <code_name> : <message>", where the category tag is[CheckerError] or[OptimizerError] as appropriate.
Public Static Functions
Private Static Functions
-
struct State#
Internal heap-allocated storage for non-OK status information.
Public Functions
-
inline State(StatusCategory cat_, StatusCode code_, std::string msg_)#
Constructs a State with the given category, code, and message.
Public Members
-
StatusCategory category = StatusCategory::NONE#
Subsystem that generated the error.
-
StatusCode code = {}#
Numeric error code.
-
inline State(StatusCategory cat_, StatusCode code_, std::string msg_)#
-
enum class StatusCategory : std::uint8_t#
-
namespace Common#