summaryrefslogtreecommitdiff
path: root/cli/deno_error.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-07-12 10:23:08 -0400
committerGitHub <noreply@github.com>2019-07-12 10:23:08 -0400
commit1fde15c0bc77e0c5cc6f7cbf27b4e072e1ad6c46 (patch)
tree06d8799033f4cc5404e5753d7628c0a3d81e810f /cli/deno_error.rs
parentabe8a113ad8004f160eac5f3f115cb28c5072ba7 (diff)
Fix REPL when it receives EOF (#2638)
Diffstat (limited to 'cli/deno_error.rs')
-rw-r--r--cli/deno_error.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli/deno_error.rs b/cli/deno_error.rs
index 717924701..544a411ba 100644
--- a/cli/deno_error.rs
+++ b/cli/deno_error.rs
@@ -8,6 +8,7 @@ use deno::ErrBox;
use deno::ModuleResolutionError;
use http::uri;
use hyper;
+use rustyline::error::ReadlineError;
use std;
use std::error::Error;
use std::fmt;
@@ -185,6 +186,19 @@ impl GetErrorKind for hyper::Error {
}
}
+impl GetErrorKind for ReadlineError {
+ fn kind(&self) -> ErrorKind {
+ use ReadlineError::*;
+ match self {
+ Io(err) => GetErrorKind::kind(err),
+ Eof => ErrorKind::UnexpectedEof,
+ #[cfg(unix)]
+ Errno(err) => err.kind(),
+ _ => unimplemented!(),
+ }
+ }
+}
+
#[cfg(unix)]
mod unix {
use super::{ErrorKind, GetErrorKind};
@@ -230,6 +244,7 @@ impl GetErrorKind for dyn AnyError {
.or_else(|| self.downcast_ref::<StaticError>().map(Get::kind))
.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(|| unix_error_kind(self))
.unwrap_or_else(|| {
panic!("Can't get ErrorKind for {:?}", self);