thruput_sdk/exn/
wrapper.rs1use crate::ContractTypeSpec;
2use crate::exn::fault::*;
3use crate::xdr::*;
4use core::fmt::Debug;
5#[cfg(not(target_arch = "riscv32"))]
6use thiserror::Error;
7
8#[derive(
13 Debug, PartialEq, ReadXDR, WriteXDR, ContractTypeSpec, ConstXDRSize,
14)]
15#[cfg_attr(not(target_arch = "riscv32"), derive(Error))]
16#[repr(i32)]
17pub enum CallingError {
18 #[cfg_attr(
19 not(target_arch = "riscv32"),
20 error("Invalid call: contract not found (or bad auth tokens)")
21 )]
22 Invalid = 0,
23
24 #[cfg_attr(
25 not(target_arch = "riscv32"),
26 error("Decoding a successful result: {0}")
27 )]
28 DecodingSuccess(FaultString) = 1,
29
30 #[cfg_attr(
31 not(target_arch = "riscv32"),
32 error("Decoding an exception result: {0}")
33 )]
34 DecodingException(FaultString) = 2,
35
36 #[cfg_attr(not(target_arch = "riscv32"), error("Encoding arguments: {0}"))]
37 EncodingArgs(FaultString) = 3,
38
39 #[cfg_attr(
42 not(target_arch = "riscv32"),
43 error("Invalid call: target already has an open frame (reentrant)")
44 )]
45 Reentrance = 4,
46
47 #[cfg_attr(
51 not(target_arch = "riscv32"),
52 error("Invalid call: cross-invoke depth bound reached")
53 )]
54 DepthExceeded = 5,
55}
56
57impl crate::re_throw::ReThrow for CallingError {
60 #[cfg_attr(not(target_arch = "riscv32"), track_caller)]
61 fn re_throw(self) -> ! {
62 crate::exn::client_library_throw(self)
63 }
64}
65
66#[derive(
68 Debug, PartialEq, ReadXDR, WriteXDR, ContractTypeSpec, ConstXDRSize,
69)]
70#[cfg_attr(not(target_arch = "riscv32"), derive(Error))]
71#[repr(i32)]
72pub enum HandlingError {
73 #[cfg_attr(
74 not(target_arch = "riscv32"),
75 error("Decoding argument data: {0}")
76 )]
77 DecodingArgs(FaultString) = 0,
78
79 #[cfg_attr(
80 not(target_arch = "riscv32"),
81 error("Encoding successful result: {0}")
82 )]
83 EncodingSuccess(FaultString) = 1,
84
85 #[cfg_attr(
86 not(target_arch = "riscv32"),
87 error("Encoding exception result: {0}")
88 )]
89 EncodingException(FaultString) = 2,
90
91 #[cfg_attr(not(target_arch = "riscv32"), error("Encoding event: {0}"))]
92 EncodingEvent(FaultString) = 3,
93}
94
95#[derive(
97 Debug, PartialEq, ReadXDR, WriteXDR, ContractTypeSpec, ConstXDRSize,
98)]
99#[cfg_attr(not(target_arch = "riscv32"), derive(Error))]
100#[repr(i32)]
101pub enum AuthTokenError {
102 #[cfg_attr(
103 not(target_arch = "riscv32"),
104 error("Encoding auth token: {0}")
105 )]
106 MintEncodeFailure(FaultString) = 0,
107 #[cfg_attr(
108 not(target_arch = "riscv32"),
109 error("Decoding auth token payload: {0}")
110 )]
111 ConsumeDecodeFailure(FaultString) = 1,
112
113 #[cfg_attr(
114 not(target_arch = "riscv32"),
115 error("Receiving auth token handles: {0}")
116 )]
117 ReceiveAuthHandlesFailure(FaultString) = 2,
118}
119
120impl crate::__contract_spec::ContractTypeName for CallingError {
121 const NAME: crate::__contract_spec::ContractSpecIdView<'static> =
122 crate::__contract_spec::ContractSpecIdView {
123 crate_name: ::core::env!("CARGO_PKG_NAME"),
124 major: crate::exn::EXN_ABI_MAJOR,
125 module_path: ::core::module_path!(),
126 declared: "CallingError",
127 };
128}
129
130impl crate::__contract_spec::ContractTypeName for HandlingError {
131 const NAME: crate::__contract_spec::ContractSpecIdView<'static> =
132 crate::__contract_spec::ContractSpecIdView {
133 crate_name: ::core::env!("CARGO_PKG_NAME"),
134 major: crate::exn::EXN_ABI_MAJOR,
135 module_path: ::core::module_path!(),
136 declared: "HandlingError",
137 };
138}
139
140impl crate::__contract_spec::ContractTypeName for AuthTokenError {
141 const NAME: crate::__contract_spec::ContractSpecIdView<'static> =
142 crate::__contract_spec::ContractSpecIdView {
143 crate_name: ::core::env!("CARGO_PKG_NAME"),
144 major: crate::exn::EXN_ABI_MAJOR,
145 module_path: ::core::module_path!(),
146 declared: "AuthTokenError",
147 };
148}