pop_contracts/
errors.rs

1// SPDX-License-Identifier: GPL-3.0
2
3use pop_common::sourcing::Error as SourcingError;
4use thiserror::Error;
5
6/// Represents the various errors that can occur in the crate.
7#[derive(Error, Debug)]
8#[allow(clippy::enum_variant_names)]
9pub enum Error {
10	/// An error occurred.
11	#[error("Anyhow error: {0}")]
12	AnyhowError(#[from] anyhow::Error),
13	/// Failed to parse a balance value from a string representation.
14	#[error("Failed to parse balance: {0}")]
15	BalanceParsing(String),
16	/// Failed to call the smart contract.
17	#[error("{0}")]
18	CallContractError(String),
19	/// A common error originating from `pop_common`.
20	#[error("{0}")]
21	CommonError(#[from] pop_common::Error),
22	/// Dry-run contract upload failed.
23	#[error("Pre-submission dry-run failed: {0}")]
24	DryRunUploadContractError(String),
25	/// Dry-run contract call failed.
26	#[error("Pre-submission dry-run failed: {0}")]
27	DryRunCallContractError(String),
28	/// Failed to parse hex-encoded bytes.
29	#[error("Failed to parse hex encoded bytes: {0}")]
30	HexParsing(String),
31	/// An HTTP request failed.
32	#[error("HTTP error: {0}")]
33	HttpError(#[from] reqwest::Error),
34	/// The number of provided arguments did not match the expected count.
35	#[error("Incorrect number of arguments provided. Expecting {expected}, {provided} provided")]
36	IncorrectArguments {
37		/// Number of arguments expected.
38		expected: usize,
39		/// Number of arguments provided.
40		provided: usize,
41	},
42	/// Failed to install the contracts node binary.
43	#[error("Failed to install {0}")]
44	InstallContractsNode(String),
45	/// Contract instantiation failed.
46	#[error("{0}")]
47	InstantiateContractError(String),
48	/// The specified constructor name is invalid.
49	#[error("Invalid constructor name: {0}")]
50	InvalidConstructorName(String),
51	/// The specified message name is invalid.
52	#[error("Invalid message name: {0}")]
53	InvalidMessageName(String),
54	/// The specified name is invalid.
55	#[error("Invalid name: {0}")]
56	InvalidName(String),
57	/// An I/O error occurred.
58	#[error("IO error: {0}")]
59	IO(#[from] std::io::Error),
60	/// An I/O error occurred.
61	#[error("Failed to get manifest path: {0}")]
62	ManifestPath(String),
63	/// Error returned when mapping an account fails.
64	#[error("Failed to map account: {0}")]
65	MapAccountError(String),
66	/// A required argument was not provided.
67	#[error("Argument {0} is required")]
68	MissingArgument(String),
69	/// An error occurred while creating a new contract project.
70	#[error("Failed to create new contract project: {0}")]
71	NewContract(String),
72	/// An error occurred while parsing a URL.
73	#[error("ParseError error: {0}")]
74	ParseError(#[from] url::ParseError),
75	/// The `Repository` property is missing from the template variant.
76	#[error("The `Repository` property is missing from the template variant")]
77	RepositoryMissing,
78	/// An error occurred sourcing a binary.
79	#[error("Sourcing error {0}")]
80	SourcingError(SourcingError),
81	/// An error occurred while executing a test command.
82	#[error("Failed to execute test command: {0}")]
83	TestCommand(String),
84	/// The platform is unsupported.
85	#[error("Unsupported platform: {os}")]
86	UnsupportedPlatform {
87		/// The operating system in use.
88		os: &'static str,
89	},
90	/// An error occurred while uploading the contract.
91	#[error("{0}")]
92	UploadContractError(String),
93}