Giter Site home page Giter Site logo

Comments (4)

AdrienChampion avatar AdrienChampion commented on August 15, 2024 1

I just updated the blog post. Note that the extension file has changed to update must_fail.

The discussion in External Contract Example about must_fail has been updated to show how to catch the error message of a failure.

Let me know if this works for you, and if it does, would you mind closing this issue?

from techelson.

AdrienChampion avatar AdrienChampion commented on August 15, 2024 1

Glad it works for you, let me know if you have more questions/problems!

from techelson.

AdrienChampion avatar AdrienChampion commented on August 15, 2024

Hey!

By your message you seem to be using Techelson with Liquidity. If you look at the external contract example Section in my blog post, you will see that I use Techel.must_fail which almost does what you want.

At liquidity level, you currently cannot use this extension to catch error messages. But if you look at how the extensions are defined,

external must_fail :
    [%stack: operation] -> [%stack: operation]
    = "{ NONE string ; MUST_FAIL string }"

The weird NONE string that's pushed on the stack is exactly what you want: it is the error message of the failure. I'm going to update the post to allow users to specify the error message and pass it to must_fail.

In the mean time, you can rewrite the definition of must_fail to

external must_fail :
    [%stack: string] -> [%stack: operation] -> [%stack: operation]
    = "{ DIP { SOME } ; MUST_FAIL string }"

Then you can use it as must_fail <error_string> <operation>. This will work iff <operation> fails with message <error_string>.

I'll notify you once the Liquidity blog post is updated.

Thank you!

from techelson.

asbjornenge avatar asbjornenge commented on August 15, 2024

Fantastic 🎉 Works perfectly! Thanks a bunch 🙌

from techelson.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.