From 1fde15c0bc77e0c5cc6f7cbf27b4e072e1ad6c46 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 12 Jul 2019 10:23:08 -0400 Subject: Fix REPL when it receives EOF (#2638) --- cli/deno_error.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cli/deno_error.rs') 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::().map(Get::kind)) .or_else(|| self.downcast_ref::().map(Get::kind)) .or_else(|| self.downcast_ref::().map(Get::kind)) + .or_else(|| self.downcast_ref::().map(Get::kind)) .or_else(|| unix_error_kind(self)) .unwrap_or_else(|| { panic!("Can't get ErrorKind for {:?}", self); -- cgit v1.2.3