NEWTON

NEWTON


Popular tags

    Cairo: How do I write a custom error message when an assert fails?

    Asked

    5 months ago

    5

    views


    0

    In solidity I can add an error message as the 2nd argument to require, like: require(<some_condition>, "My error message");

    Is there an equivalent way to do this in a starknet contract? Like for assert some_var = 0

    This question was originally posted on Triality

      cairostarknet

    1 answers

    0

    You can wrap the assertion in with_attr, for example:

    with_attr error_message("My error message"):

    assert some_var = 0

    end

    This answer was originally posted on Triality

    answered

    6 months ago

    Your answer

    NEWTON

    NEWTON