diff options
author | Nadrieril | 2019-04-06 17:48:13 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-06 17:48:13 +0200 |
commit | 9741e3280ed03920732430e7994e1f8482c9ddd6 (patch) | |
tree | fc98320f9fa914994d6ab25a140adb411f90c82d /dhall | |
parent | 727c5219c9af55df3e61fb372fa2fadecdd15b18 (diff) |
s/DhallError/ImportError/
Diffstat (limited to '')
-rw-r--r-- | dhall/src/imports.rs | 20 | ||||
-rw-r--r-- | dhall/tests/common/mod.rs | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs index 96268ca..95cf6fa 100644 --- a/dhall/src/imports.rs +++ b/dhall/src/imports.rs @@ -22,7 +22,7 @@ pub enum ImportRoot { fn resolve_import( import: &Import, root: &ImportRoot, -) -> Result<Expr<X, X>, DhallError> { +) -> Result<Expr<X, X>, ImportError> { use self::ImportRoot::*; use dhall_core::FilePrefix::*; use dhall_core::ImportLocation::*; @@ -43,23 +43,23 @@ fn resolve_import( } #[derive(Debug)] -pub enum DhallError { +pub enum ImportError { ParseError(ParseError), IOError(std::io::Error), } -impl From<ParseError> for DhallError { +impl From<ParseError> for ImportError { fn from(e: ParseError) -> Self { - DhallError::ParseError(e) + ImportError::ParseError(e) } } -impl From<std::io::Error> for DhallError { +impl From<std::io::Error> for ImportError { fn from(e: std::io::Error) -> Self { - DhallError::IOError(e) + ImportError::IOError(e) } } -impl fmt::Display for DhallError { +impl fmt::Display for ImportError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use self::DhallError::*; + use self::ImportError::*; match self { ParseError(e) => e.fmt(f), IOError(e) => e.fmt(f), @@ -70,7 +70,7 @@ impl fmt::Display for DhallError { pub fn load_dhall_file( f: &Path, resolve_imports: bool, -) -> Result<Expr<X, X>, DhallError> { +) -> Result<Expr<X, X>, ImportError> { let mut buffer = String::new(); File::open(f)?.read_to_string(&mut buffer)?; let expr = parse_expr(&*buffer)?; @@ -88,7 +88,7 @@ pub fn load_dhall_file( pub fn load_dhall_file_no_resolve_imports( f: &Path, -) -> Result<ParsedExpr, DhallError> { +) -> Result<ParsedExpr, ImportError> { let mut buffer = String::new(); File::open(f)?.read_to_string(&mut buffer)?; let expr = parse_expr(&*buffer)?; diff --git a/dhall/tests/common/mod.rs b/dhall/tests/common/mod.rs index 397a8ee..e748cf0 100644 --- a/dhall/tests/common/mod.rs +++ b/dhall/tests/common/mod.rs @@ -44,13 +44,13 @@ pub enum Feature { TypeInferenceFailure, } -pub fn read_dhall_file<'i>(file_path: &str) -> Result<Expr<X, X>, DhallError> { +pub fn read_dhall_file<'i>(file_path: &str) -> Result<Expr<X, X>, ImportError> { load_dhall_file(&PathBuf::from(file_path), true) } pub fn read_dhall_file_no_resolve_imports<'i>( file_path: &str, -) -> Result<ParsedExpr, DhallError> { +) -> Result<dhall_core::ParsedExpr, ImportError> { load_dhall_file_no_resolve_imports(&PathBuf::from(file_path)) } @@ -93,7 +93,7 @@ pub fn run_test(base_path: &str, feature: Feature) { let err = read_dhall_file_no_resolve_imports(&file_path).unwrap_err(); match err { - DhallError::ParseError(_) => {} + ImportError::ParseError(_) => {} e => panic!("Expected parse error, got: {:?}", e), } } |