PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, July 28, 2022

[FIXED] How to define Move Error types in Sui blockchain

 July 28, 2022     blockchain, move-lang, smartcontracts, sui     No comments   

Issue

Trying to understand the idiomatic way we should set Errors in Sui blockchain smart contracts.

From the provided examples it seems that we should define constants per different expected error i.e. in Marketplace smart contract two errors are defined:

// For when amount paid does not match the expected.
const EAmountIncorrect: u64 = 0;

// For when someone tries to delist without ownership.
const ENotOwner: u64 = 1;

Questions:

  • what is the idiomatic Move-language way to name the error constants, starting with the E character then camel case?
  • what if a dev assigns the same number to two or more errors?

Solution

what is the idiomatic Move-language way to name the error constants, starting with the E character then camel case?

That's right.

what if a dev assigns the same number to two or more errors?

The author of a Move module is free to assign the same number to more than one errors since they are no different from regular constants. It is up to the consumer of the Move module how to interpret the error codes returned from the Move VM. Sui Move itself doesn't prohibit two error constants from having the same value. We may, however, add a module to Sui stdlib defining an error standard in the future.



Answered By - emma
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing