summaryrefslogtreecommitdiff
path: root/cli/deno_error.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-08-26 14:50:21 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-26 08:50:21 -0400
commit520f9631e09aa720fd8c03513ee8ea967f5ed4b2 (patch)
treefc3d1bd5182452ca1865a5c2631355e0895af94c /cli/deno_error.rs
parent017f88ee99b0fe40221e6af92e0b6a976fbaf2ad (diff)
bring back json ops (#2815)
Diffstat (limited to 'cli/deno_error.rs')
-rw-r--r--cli/deno_error.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/deno_error.rs b/cli/deno_error.rs
index e024a396c..3b7dbcde8 100644
--- a/cli/deno_error.rs
+++ b/cli/deno_error.rs
@@ -205,6 +205,18 @@ impl GetErrorKind for ReadlineError {
}
}
+impl GetErrorKind for serde_json::error::Error {
+ fn kind(&self) -> ErrorKind {
+ use serde_json::error::*;
+ match self.classify() {
+ Category::Io => ErrorKind::InvalidInput,
+ Category::Syntax => ErrorKind::InvalidInput,
+ Category::Data => ErrorKind::InvalidData,
+ Category::Eof => ErrorKind::UnexpectedEof,
+ }
+ }
+}
+
#[cfg(unix)]
mod unix {
use super::{ErrorKind, GetErrorKind};
@@ -251,6 +263,11 @@ impl GetErrorKind for dyn AnyError {
.or_else(|| self.downcast_ref::<uri::InvalidUri>().map(Get::kind))
.or_else(|| self.downcast_ref::<url::ParseError>().map(Get::kind))
.or_else(|| self.downcast_ref::<ReadlineError>().map(Get::kind))
+ .or_else(|| {
+ self
+ .downcast_ref::<serde_json::error::Error>()
+ .map(Get::kind)
+ })
.or_else(|| unix_error_kind(self))
.unwrap_or_else(|| {
panic!("Can't get ErrorKind for {:?}", self);