near_workspaces/error/
mod.rs1pub(crate) mod execution;
5mod impls;
6
7use std::borrow::Cow;
8
9use crate::result::ExecutionFailure;
10
11#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
13#[non_exhaustive]
14pub enum ErrorKind {
15 #[error("{0}")]
17 Rpc(#[from] RpcErrorCode),
18 #[error("Execution")]
20 Execution,
21 #[error("{0}")]
23 Sandbox(#[from] SandboxErrorCode),
24 #[error("IO")]
26 Io,
27 #[error("DataConversion")]
29 DataConversion,
30 #[error("Other")]
32 Other,
33}
34
35#[derive(Debug, thiserror::Error)]
36enum ErrorRepr {
37 #[error("{0}")]
38 Simple(ErrorKind),
39 #[error("{message}")]
40 Message {
41 kind: ErrorKind,
42 message: Cow<'static, str>,
43 },
44 #[error("{kind}")]
45 Custom {
46 kind: ErrorKind,
47 #[source]
48 error: Box<dyn std::error::Error + Send + Sync>,
49 },
50 #[error("{message}")]
51 Full {
52 kind: ErrorKind,
53 message: Cow<'static, str>,
54 #[source]
55 error: Box<dyn std::error::Error + Send + Sync>,
56 },
57 #[error("{error}")]
58 Detailed {
59 kind: ErrorKind,
60 error: Box<ExecutionFailure>,
62 },
63}
64
65#[derive(Debug)]
68pub struct Error {
69 repr: ErrorRepr,
70}
71
72#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
73#[non_exhaustive]
74pub enum SandboxErrorCode {
75 #[error("Sandbox has already been started")]
76 AlreadyStarted,
77 #[error("Could not initialize sandbox node")]
78 InitFailure,
79 #[error("Could not startup and run sandbox node")]
80 RunFailure,
81 #[error("Sandbox failed to patch state")]
82 PatchStateFailure,
83 #[error("Sandbox failed to fast forward")]
84 FastForwardFailure,
85}
86
87#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
88#[non_exhaustive]
89pub enum RpcErrorCode {
90 #[error("unable to create a new account via helper")]
91 HelperAccountCreationFailure,
92 #[error("failed to connect to rpc service")]
93 ConnectionFailure,
94 #[error("access key was unable to be retrieved")]
95 UnableToRetrieveAccessKey,
96 #[error("unable to broadcast the transaction to the network")]
97 BroadcastTxFailure,
98 #[error("unable to call into a view function")]
99 ViewFunctionFailure,
100 #[error("unable to fulfill the query request")]
101 QueryFailure,
102 #[error("incorrect variant retrieved while querying (maybe a bug in RPC code?)")]
103 QueryReturnedInvalidData,
104}