Skip to content
On this page

Exceptions

On Tezos, exceptions cannot be caught, the whole transaction is backtracked if an exception occurs.

INFO

A transaction starts with the call from an implicit account (tz1 accounts) and includes all the subsequent operations (transfers, contract origination, etc.).

For example: if Alice calls contract B, contract B calls contract C and contract C raises an exception then everything is backtracked. Alice's call never occurred.

raise  x: t → 

Aborts the current transaction and raises an error x of type t.

smartpy
raise "NotAdmin"
raise ("TOKEN_UNDEFINED", 404)
assert  x: bool, exception: t → 

Checks that x evaluates to True and raises an exception if it doesn’t.

smartpy
assert sp.sender == self.data.administrator, "NotAdmin"