Skip to content

src/scale/scale_error.hpp

Namespaces

Name
sgns
sgns::scale

Types

Name
enum class EncodeError { COMPACT_INTEGER_TOO_BIG = 1, NEGATIVE_COMPACT_INTEGER, WRONG_CATEGORY, WRONG_ALTERNATIVE, DEREF_NULLPOINTER}
EncodeError enum provides error codes for Encode methods.
enum class DecodeError { NOT_ENOUGH_DATA = 1, UNEXPECTED_VALUE, TOO_MANY_ITEMS, WRONG_TYPE_INDEX, INVALID_DATA, OUT_OF_BOUNDARIES}
DecoderError enum provides codes of errors for Decoder methods.
enum class CommonError { UNKNOWN_ERROR = 1}
base errors

Types Documentation

enum EncodeError

Enumerator Value Description
COMPACT_INTEGER_TOO_BIG 1 compact integer can't be more than 2**536
NEGATIVE_COMPACT_INTEGER cannot compact-encode negative integers
WRONG_CATEGORY wrong compact category
WRONG_ALTERNATIVE wrong cast to alternative
DEREF_NULLPOINTER dereferencing a null pointer

EncodeError enum provides error codes for Encode methods.

enum DecodeError

Enumerator Value Description
NOT_ENOUGH_DATA 1 not enough data to decode value
UNEXPECTED_VALUE unexpected value
TOO_MANY_ITEMS too many items, cannot address them in memory
WRONG_TYPE_INDEX wrong type index, cannot decode variant
INVALID_DATA invalid data
OUT_OF_BOUNDARIES advance went out of boundaries

DecoderError enum provides codes of errors for Decoder methods.

enum CommonError

Enumerator Value Description
UNKNOWN_ERROR 1 unknown error

base errors

Source code

#ifndef SUPERGENIUS_SCALE_ERROR_HPP
#define SUPERGENIUS_SCALE_ERROR_HPP

#include "outcome/outcome.hpp"

namespace sgns::scale {
  enum class EncodeError {        // 0 is reserved for success
    COMPACT_INTEGER_TOO_BIG = 1,  
    NEGATIVE_COMPACT_INTEGER,     
    WRONG_CATEGORY,               
    WRONG_ALTERNATIVE,            
    DEREF_NULLPOINTER,            
  };

  enum class DecodeError {  // 0 is reserved for success
    NOT_ENOUGH_DATA = 1,    
    UNEXPECTED_VALUE,       
    TOO_MANY_ITEMS,         
    WRONG_TYPE_INDEX,       
    INVALID_DATA,           
    OUT_OF_BOUNDARIES       
  };

  enum class CommonError {
    UNKNOWN_ERROR = 1  
  };
}  // namespace sgns::scale

OUTCOME_HPP_DECLARE_ERROR_2(sgns::scale, EncodeError)
OUTCOME_HPP_DECLARE_ERROR_2(sgns::scale, DecodeError)
OUTCOME_HPP_DECLARE_ERROR_2(sgns::scale, CommonError)

#endif  // SUPERGENIUS_SCALE_ERROR_HPP

Updated on 2026-03-04 at 13:10:45 -0800