-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Refactored gluer && Added error type && Updated example
- Loading branch information
Showing
5 changed files
with
287 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::fmt::Debug; | ||
|
||
/// Result type containing the custom error enum | ||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
/// Error type containing all error cases with extra metadata | ||
pub enum Error { | ||
/// An io operation failed | ||
FileSystem(std::io::Error), | ||
/// Parsing to Typescript failed | ||
Ts(String), | ||
} | ||
|
||
impl Debug for Error { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Error::FileSystem(e) => write!(f, "FileSystem: {}", e), | ||
Error::Ts(e) => write!(f, "Ts: {}", e), | ||
} | ||
} | ||
} | ||
|
||
impl From<std::io::Error> for Error { | ||
fn from(e: std::io::Error) -> Self { | ||
Error::FileSystem(e) | ||
} | ||
} |
Oops, something went wrong.