mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 20:21:38 +00:00
Add error for malformed project files
This commit is contained in:
parent
dfabc07044
commit
e5684ad947
2 changed files with 15 additions and 2 deletions
|
|
@ -39,6 +39,16 @@ impl SnapshotError {
|
|||
path: Some(path.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn malformed_project(
|
||||
inner: serde_json::Error,
|
||||
path: impl Into<PathBuf>,
|
||||
) -> SnapshotError {
|
||||
SnapshotError {
|
||||
detail: SnapshotErrorDetail::MalformedProject { inner },
|
||||
path: Some(path.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for SnapshotError {
|
||||
|
|
@ -72,6 +82,7 @@ pub enum SnapshotErrorDetail {
|
|||
FileDidNotExist,
|
||||
FileNameBadUnicode,
|
||||
FileContentsBadUnicode { inner: std::str::Utf8Error },
|
||||
MalformedProject { inner: serde_json::Error },
|
||||
}
|
||||
|
||||
impl SnapshotErrorDetail {
|
||||
|
|
@ -81,6 +92,7 @@ impl SnapshotErrorDetail {
|
|||
match self {
|
||||
IoError { inner } => Some(inner),
|
||||
FileContentsBadUnicode { inner } => Some(inner),
|
||||
MalformedProject { inner } => Some(inner),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -97,6 +109,7 @@ impl fmt::Display for SnapshotErrorDetail {
|
|||
FileContentsBadUnicode { inner } => {
|
||||
write!(formatter, "file had malformed unicode: {}", inner)
|
||||
}
|
||||
MalformedProject { inner } => write!(formatter, "{}", inner),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue