Skip to content

Standardized errors #936

Open
Open
@itegulov

Description

Right now it is unclear what kind of errors a contract (or even a function) can fail with. It would be nice to have a standardized way of declaring contract errors, something like this:

#[near_error]
pub enum MyError {
  #[message("Caller is not the owner of this contract")]
  NotTheOwner,
  #[message("Caller is not allowed to call this function")]
  NotAllowed,
}

We can then include all contract errors as a part of the ABI, this proposal also goes really well with the Result-based error handling as we can statically infer what errors a function can fail with.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status

      NEW❗

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions