Programming Language

Nocter

A self-contained systems language built around simplicity, encapsulation, and foolproof design.

/std/error/index.nct

index.nct

//! Construction for the compiler built-in failure payload.
//!
//! Error codes are open UTF-8 strings. Standard-library and user-library code
//! use dotted codes such as "std.io.not_found" or "app.config.missing_key".

see ./construction.nct

/// The uniform recoverable failure payload carried by `T!`.
pub primitive type error

construct error {
    /// Creates a failure with one stable code and user-facing message.
    pub noalloc func new(code: &str, message: &str): Self
}

instance error {
    /// Returns the same code with `message` as its new outer context.
    pub noalloc method self.context(message: &str): Self

    /// Returns the stable machine-readable failure code.
    pub noalloc method &self.code(): &str from self

    /// Returns the current user-facing failure message.
    pub noalloc method &self.message(): &str from self

    /// Reports whether this failure carries the exact supplied code.
    pub noalloc method &self.has_code(code: &str): bool
}