mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 02:24:15 +03:00
deprecate crate failure in favor of thiserror
This commit is contained in:
parent
6ab1ce6e71
commit
abb50628a0
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -478,7 +478,6 @@ dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
"env_logger",
|
||||
"failure",
|
||||
"from-pest",
|
||||
"leo-compiler",
|
||||
"log",
|
||||
@ -493,6 +492,7 @@ dependencies = [
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
"structopt",
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
|
@ -28,7 +28,6 @@ snarkos-utilities = { path = "../snarkOS/utilities", version = "0.8.0" }
|
||||
clap = { version = "2.33.0" }
|
||||
colored = { version = "1.9" }
|
||||
env_logger = { version = "0.7" }
|
||||
failure = { version = "0.1.5" }
|
||||
from-pest = { version = "0.3.1" }
|
||||
log = { version = "0.4" }
|
||||
rand = { version = "0.7" }
|
||||
@ -37,3 +36,4 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0" }
|
||||
structopt = { version = "0.3.14" }
|
||||
toml = { version = "0.5" }
|
||||
thiserror = { version = "1.0" }
|
||||
|
@ -88,8 +88,8 @@ impl CLI for BuildCommand {
|
||||
// bt: vec![],
|
||||
// ct: vec![],
|
||||
// };
|
||||
program.evaluate_program::<KeypairAssembly::<Bls12_377>>()?;
|
||||
}
|
||||
program.evaluate_program::<KeypairAssembly::<Bls12_377>>()?;
|
||||
|
||||
log::info!("Compiled program in {:?}", main_file_path);
|
||||
|
||||
|
@ -1,47 +1,47 @@
|
||||
use crate::errors::*;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CLIError {
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
BuildError(BuildError),
|
||||
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ChecksumFileError(ChecksumFileError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
InitError(InitError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
InputsDirectoryError(InputsDirectoryError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
MainFileError(MainFileError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ManifestError(ManifestError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
NewError(NewError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
OutputsDirectoryError(OutputsDirectoryError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ProofFileError(ProofFileError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ProvingKeyFileError(ProvingKeyFileError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
RunError(RunError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
SourceDirectoryError(SourceDirectoryError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
VerificationKeyFileError(VerificationKeyFileError),
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,12 @@ use crate::errors::ManifestError;
|
||||
|
||||
use std::ffi::OsString;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum BuildError {
|
||||
#[fail(display = "main file {:?} does not exist", _0)]
|
||||
#[error("main file {:?} does not exist", _0)]
|
||||
MainFileDoesNotExist(OsString),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ManifestError(ManifestError),
|
||||
}
|
||||
|
||||
|
@ -3,21 +3,21 @@ use crate::errors::ManifestError;
|
||||
use std::ffi::OsString;
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum InitError {
|
||||
#[fail(display = "root directory {:?} creating: {}", _0, _1)]
|
||||
#[error("root directory {:?} creating: {}", _0, _1)]
|
||||
CreatingRootDirectory(OsString, io::Error),
|
||||
|
||||
#[fail(display = "directory {:?} does not exist", _0)]
|
||||
#[error("directory {:?} does not exist", _0)]
|
||||
DirectoryDoesNotExist(OsString),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ManifestError(ManifestError),
|
||||
|
||||
#[fail(display = "package at path {:?} already exists", _0)]
|
||||
#[error("package at path {:?} already exists", _0)]
|
||||
PackageAlreadyExists(OsString),
|
||||
|
||||
#[fail(display = "package name is missing - {:?}", _0)]
|
||||
#[error("package name is missing - {:?}", _0)]
|
||||
ProjectNameInvalid(OsString),
|
||||
}
|
||||
|
||||
|
@ -3,21 +3,21 @@ use crate::errors::ManifestError;
|
||||
use std::ffi::OsString;
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum NewError {
|
||||
#[fail(display = "root directory {:?} creating: {}", _0, _1)]
|
||||
#[error("root directory {:?} creating: {}", _0, _1)]
|
||||
CreatingRootDirectory(OsString, io::Error),
|
||||
|
||||
#[fail(display = "directory {:?} already exists", _0)]
|
||||
#[error("directory {:?} already exists", _0)]
|
||||
DirectoryAlreadyExists(OsString),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ManifestError(ManifestError),
|
||||
|
||||
#[fail(display = "package at path {:?} already exists", _0)]
|
||||
#[error("package at path {:?} already exists", _0)]
|
||||
PackageAlreadyExists(OsString),
|
||||
|
||||
#[fail(display = "package name is missing - {:?}", _0)]
|
||||
#[error("package name is missing - {:?}", _0)]
|
||||
ProjectNameInvalid(OsString),
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,12 @@ use crate::errors::ManifestError;
|
||||
|
||||
use std::ffi::OsString;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RunError {
|
||||
#[fail(display = "main file {:?} does not exist", _0)]
|
||||
#[error("main file {:?} does not exist", _0)]
|
||||
MainFileDoesNotExist(OsString),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
#[error("{}", _0)]
|
||||
ManifestError(ManifestError),
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
use std::{ffi::OsString, fs::FileType, io};
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum InputsDirectoryError {
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "file entry getting: {}", _0)]
|
||||
#[error("file entry getting: {}", _0)]
|
||||
GettingFileEntry(io::Error),
|
||||
|
||||
#[fail(display = "file {:?} extension getting", _0)]
|
||||
#[error("file {:?} extension getting", _0)]
|
||||
GettingFileExtension(OsString),
|
||||
|
||||
#[fail(display = "file {:?} type getting: {}", _0, _1)]
|
||||
#[error("file {:?} type getting: {}", _0, _1)]
|
||||
GettingFileType(OsString, io::Error),
|
||||
|
||||
#[fail(display = "invalid file {:?} extension: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} extension: {:?}", _0, _1)]
|
||||
InvalidFileExtension(OsString, OsString),
|
||||
|
||||
#[fail(display = "invalid file {:?} type: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} type: {:?}", _0, _1)]
|
||||
InvalidFileType(OsString, FileType),
|
||||
|
||||
#[fail(display = "reading: {}", _0)]
|
||||
#[error("reading: {}", _0)]
|
||||
Reading(io::Error),
|
||||
}
|
||||
|
@ -1,28 +1,28 @@
|
||||
use std::{ffi::OsString, fs::FileType, io};
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OutputsDirectoryError {
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "file entry getting: {}", _0)]
|
||||
#[error("file entry getting: {}", _0)]
|
||||
GettingFileEntry(io::Error),
|
||||
|
||||
#[fail(display = "file {:?} extension getting", _0)]
|
||||
#[error("file {:?} extension getting", _0)]
|
||||
GettingFileExtension(OsString),
|
||||
|
||||
#[fail(display = "file {:?} type getting: {}", _0, _1)]
|
||||
#[error("file {:?} type getting: {}", _0, _1)]
|
||||
GettingFileType(OsString, io::Error),
|
||||
|
||||
#[fail(display = "invalid file {:?} extension: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} extension: {:?}", _0, _1)]
|
||||
InvalidFileExtension(OsString, OsString),
|
||||
|
||||
#[fail(display = "invalid file {:?} type: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} type: {:?}", _0, _1)]
|
||||
InvalidFileType(OsString, FileType),
|
||||
|
||||
#[fail(display = "reading: {}", _0)]
|
||||
#[error("reading: {}", _0)]
|
||||
Reading(io::Error),
|
||||
|
||||
#[fail(display = "removing: {}", _0)]
|
||||
#[error("removing: {}", _0)]
|
||||
Removing(io::Error),
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
use std::{ffi::OsString, fs::FileType, io};
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SourceDirectoryError {
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "file entry getting: {}", _0)]
|
||||
#[error("file entry getting: {}", _0)]
|
||||
GettingFileEntry(io::Error),
|
||||
|
||||
#[fail(display = "file {:?} extension getting", _0)]
|
||||
#[error("file {:?} extension getting", _0)]
|
||||
GettingFileExtension(OsString),
|
||||
|
||||
#[fail(display = "file {:?} type getting: {}", _0, _1)]
|
||||
#[error("file {:?} type getting: {}", _0, _1)]
|
||||
GettingFileType(OsString, io::Error),
|
||||
|
||||
#[fail(display = "invalid file {:?} extension: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} extension: {:?}", _0, _1)]
|
||||
InvalidFileExtension(OsString, OsString),
|
||||
|
||||
#[fail(display = "invalid file {:?} type: {:?}", _0, _1)]
|
||||
#[error("invalid file {:?} type: {:?}", _0, _1)]
|
||||
InvalidFileType(OsString, FileType),
|
||||
|
||||
#[fail(display = "reading: {}", _0)]
|
||||
#[error("reading: {}", _0)]
|
||||
Reading(io::Error),
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ChecksumFileError {
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "Cannot read from the provided file path - {:?}", _0)]
|
||||
#[error("Cannot read from the provided file path - {:?}", _0)]
|
||||
FileReadError(PathBuf),
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
#[error("writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MainFileError {
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
#[error("writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ProofFileError {
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "Cannot read from the provided file path - {:?}", _0)]
|
||||
#[error("Cannot read from the provided file path - {:?}", _0)]
|
||||
FileReadError(PathBuf),
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
#[error("writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ProvingKeyFileError {
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "Cannot read from the provided file path - {:?}", _0)]
|
||||
#[error("Cannot read from the provided file path - {:?}", _0)]
|
||||
FileReadError(PathBuf),
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
#[error("writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum VerificationKeyFileError {
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
#[error("{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "Cannot read from the provided file path - {:?}", _0)]
|
||||
#[error("Cannot read from the provided file path - {:?}", _0)]
|
||||
FileReadError(PathBuf),
|
||||
|
||||
#[fail(display = "Verification key file was corrupted")]
|
||||
#[error("Verification key file was corrupted")]
|
||||
IncorrectVerificationKey,
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
#[error("writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ManifestError {
|
||||
#[fail(display = "`{}` creating: {}", _0, _1)]
|
||||
#[error("`{}` creating: {}", _0, _1)]
|
||||
Creating(&'static str, io::Error),
|
||||
|
||||
#[fail(display = "`{}` metadata: {}", _0, _1)]
|
||||
#[error("`{}` metadata: {}", _0, _1)]
|
||||
Metadata(&'static str, io::Error),
|
||||
|
||||
#[fail(display = "`{}` opening: {}", _0, _1)]
|
||||
#[error("`{}` opening: {}", _0, _1)]
|
||||
Opening(&'static str, io::Error),
|
||||
|
||||
#[fail(display = "`{}` parsing: {}", _0, _1)]
|
||||
#[error("`{}` parsing: {}", _0, _1)]
|
||||
Parsing(&'static str, toml::de::Error),
|
||||
|
||||
#[fail(display = "`{}` reading: {}", _0, _1)]
|
||||
#[error("`{}` reading: {}", _0, _1)]
|
||||
Reading(&'static str, io::Error),
|
||||
|
||||
#[fail(display = "`{}` writing: {}", _0, _1)]
|
||||
#[error("`{}` writing: {}", _0, _1)]
|
||||
Writing(&'static str, io::Error),
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ impl MainFile {
|
||||
fn template(&self) -> String {
|
||||
format!(
|
||||
r#"// The '{}' main function.
|
||||
function main() -> (u32) {{
|
||||
a = 1 + 1;
|
||||
function main() -> u32 {{
|
||||
let a = 1 + 1;
|
||||
return a
|
||||
}}
|
||||
"#,
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[macro_use]
|
||||
extern crate failure;
|
||||
extern crate thiserror;
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
pub mod cli;
|
||||
|
Loading…
Reference in New Issue
Block a user