Skip to main content

PrologError

Enum PrologError 

Source
pub enum PrologError {
    Instantiation {
        context: String,
    },
    Type {
        expected_type: &'static str,
        culprit: Term,
        context: String,
    },
    Existence {
        object_type: &'static str,
        culprit: Term,
        context: String,
    },
    Domain {
        expected_domain: &'static str,
        culprit: Term,
        context: String,
    },
    Evaluation {
        kind: &'static str,
        context: String,
    },
    Permission {
        operation: &'static str,
        permission_type: &'static str,
        culprit: Term,
        context: String,
    },
    Representation {
        flag: &'static str,
        context: String,
    },
    Resource {
        kind: &'static str,
        context: String,
    },
    Syntax {
        context: String,
    },
}
Expand description

ISO formal-error vocabulary.

Variants§

§

Instantiation

An argument that must be bound was unbound.

Fields

§context: String
§

Type

An argument has the wrong type. expected_type is an atom name (e.g. “integer”, “atom”, “callable”); culprit is the offending term.

Fields

§expected_type: &'static str
§culprit: Term
§context: String
§

Existence

An object referred to by the goal does not exist. object_type is e.g. “procedure”; culprit is the indicator.

Fields

§object_type: &'static str
§culprit: Term
§context: String
§

Domain

An argument is outside the valid domain.

Fields

§expected_domain: &'static str
§culprit: Term
§context: String
§

Evaluation

Arithmetic evaluation failed (zero divisor, overflow, etc.).

Fields

§kind: &'static str
§context: String
§

Permission

Operation not permitted.

Fields

§operation: &'static str
§permission_type: &'static str
§culprit: Term
§context: String
§

Representation

Implementation-defined representation limit exceeded.

Fields

§flag: &'static str
§context: String
§

Resource

Resource limit exhausted. Note: Resource { kind: "steps", ... } is the step-limit error and is intentionally uncatchable — see is_uncatchable.

Fields

§kind: &'static str
§context: String
§

Syntax

Syntax error during runtime term construction (e.g. number_chars/2).

Fields

§context: String

Implementations§

Source§

impl PrologError

Source

pub fn is_uncatchable(&self) -> bool

Step-limit and other safety-ceiling errors must not be catchable by catch/3 — otherwise a malicious rule could loop indefinitely by trapping its own timeout. The solver checks this before consulting the catch stack.

Source

pub fn to_term(&self, interner: &mut StringInterner) -> Term

Render as the ISO term error(Formal, Context). Formal matches the variant (e.g. type_error(integer, foo)); Context is the human-readable atom (the message string interned as an atom). Test helpers grep this string for substrings.

Source

pub fn context(&self) -> &str

The human-readable context message. This is what test helpers substring-match against and what the CLI shows.

Source

pub fn to_display(&self, interner: &mut StringInterner) -> String

Render the error term as a human-readable string. Used by the CLI and the test helper for substring assertions.

Trait Implementations§

Source§

impl Clone for PrologError

Source§

fn clone(&self) -> PrologError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PrologError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.