cheatah
Class

builtins::Error

A raised error: a kind naming what went wrong and a human message.

Derives from std::runtime_error so it interoperates with C++ code that catches std::exception — that inheritance is a C++ implementation detail and is not visible from cheatah, where an Error is an ordinary value with two string fields.

Functions

fn Error · 2 overloads
Error(std::string message)source#
Error(std::string kind, std::string message)source#

An unclassified error — what raise "msg" builds.

Kind is kErrorKindError.

Parameters
message

the human-readable description.

Complexity

O(message).

Allocation

copies the message (twice: the base class keeps its own).

fn const std::string & kind() const noexcept source#

What CLASS of failure this is — the string except … of matches against.

Returns

the kind, by const reference; never empty for an Error built through these constructors.

Complexity

O(1).

Allocation

none.

fn const std::string & message() const noexcept source#

The human-readable description.

This is also what str and operator<< yield, so a caught error prints as its message rather than as a struct.

Returns

the message, by const reference.

Complexity

O(1).

Allocation

none.

Constants & variables

var std::string kind_ source#
var std::string message_ source#