Once an exception is raised, it cannot be caught.
Error messages may take a lot of space in smart contracts.
Have a look at Exception Optimization Levels.
Exceptions cannot be caught, the whole operation is backtracked if an exception occurs.
sp.failwith aborts the current transaction and raises a message of arbitrary type.
@sp.entrypoint def ep(self): sp.if self.data.x > 10: sp.failwith("x is bigger than 10")
sp.verify_equal, exceptions can also be raised by other constructions:
The exception raised is a pair containing the
This may fail with
Dividing by zero
1 / 0
Variable step in a range which is 0
sp.for i in sp.range(1, 10, step = 0)