mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 12:01:38 +00:00
Start using failure for error management
This commit is contained in:
parent
13a7c1ba81
commit
5114d12daf
4 changed files with 68 additions and 59 deletions
|
|
@ -2,9 +2,10 @@ use std::{
|
|||
path::PathBuf,
|
||||
fs::File,
|
||||
io,
|
||||
fmt,
|
||||
};
|
||||
|
||||
use failure::Fail;
|
||||
|
||||
use crate::{
|
||||
rbx_session::construct_oneoff_tree,
|
||||
project::{Project, ProjectLoadFuzzyError},
|
||||
|
|
@ -38,22 +39,16 @@ pub struct BuildOptions {
|
|||
pub output_kind: Option<OutputKind>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum BuildError {
|
||||
#[fail(display = "Could not detect what kind of file to create")]
|
||||
UnknownOutputKind,
|
||||
ProjectLoadError(ProjectLoadFuzzyError),
|
||||
IoError(io::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for BuildError {
|
||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
BuildError::UnknownOutputKind => {
|
||||
write!(output, "Could not detect what kind of output file to create")
|
||||
},
|
||||
BuildError::ProjectLoadError(inner) => write!(output, "{}", inner),
|
||||
BuildError::IoError(inner) => write!(output, "{}", inner),
|
||||
}
|
||||
}
|
||||
#[fail(display = "Project load error: {}", _0)]
|
||||
ProjectLoadError(#[fail(cause)] ProjectLoadFuzzyError),
|
||||
|
||||
#[fail(display = "IO error: {}", _0)]
|
||||
IoError(#[fail(cause)] io::Error),
|
||||
}
|
||||
|
||||
impl From<ProjectLoadFuzzyError> for BuildError {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue