You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception: Maybe.fromJust: Nothing
CallStack (from HasCallStack):
error, called at libraries/base/Data/Maybe.hs:149:21 in base:Data.Maybe
fromJust, called at src/Plutus/Model/Contract.hs:276:10 in plutus-simple-model-0.5.2.0-4fEbkvuS1hh58koi6xqmzV:Plutus.Model.Contract
It forces user to dive into PSM source code to figure out the reason of the error, which is not the best user experience.
Proposed solution
Make a descriptive error message.
Maybe even take optional error message as a function parameter.
The text was updated successfully, but these errors were encountered:
There's a function called withSpend :: PubKeyHash -> Value -> (UserSpend -> Run ()) -> Run () that serves the same purpose as spend and logs an error if an user doesn't have enough funds. Maybe that can be an awnser to your requirement, or could be that there are other errors that should be catched from your point of view?
Hi, @AgustinBadi.
It's good that such a function exists, but in general in a program (especially in a library) when a function fails it should be clear where and/or why.
I think Exception: Maybe.fromJust: Nothing is not something we expect to see when using library which is not base.
The solution is simply throwing custom (not necessary defined by the library user) error on Nothing instead of using fromJust.
Plutus.Model.Contract.spend fails with:
It forces user to dive into PSM source code to figure out the reason of the error, which is not the best user experience.
Proposed solution
Make a descriptive error message.
Maybe even take optional error message as a function parameter.
The text was updated successfully, but these errors were encountered: