Repository navigation
Fix the try_ result nesting in the smart-contracts skill - #170
Merged
Merged
Conversation
Generated try_foo() methods return Result<Result<T, _>, Result<E, InvokeError>>, so the contract's typed error is Err(Ok(e)), not Ok(Err(e)). Spell out what each arm means, note that functions without a Result return use soroban_sdk::Error as E, and that budget and footprint failures are not recoverable. Add an eval scenario for matching a typed error in a test.
|
Contributor
Author
|
🤖 Automated message from the Stellar Triage Bot. Verification at
Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Automated message from the Stellar Triage Bot.
Closes #163. Generated
try_foo()methods returnResult<Result<T, _>, Result<E, InvokeError>>, so the typed contract error isErr(Ok(e)).try_sentence indevelopment.mdwith the meaning of each arm and anassert_eq!example.Resultreturn usessoroban_sdk::ErrorasE.try_cannot catch them. The old text listed "budget" as a catchable error.smart-contracts/06-try-error-matching.json.Verified on
soroban-sdk29.0.1 in a scratch crate:cargo testpasses forErr(Ok(ContractError::InvalidAmount)),Err(Err(InvokeError::Abort))on a failed auth in aResultfunction, andErr(Ok(Error(Context, InvalidAction)))in a plain function.