summaryrefslogtreecommitdiff
path: root/cli/deno_error.rs
diff options
context:
space:
mode:
authorJed Fox <git@twopointzero.us>2019-10-02 11:55:28 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-10-02 11:55:28 -0400
commit99eec73b4b8813c6db7cae83f5415b031de0c2c7 (patch)
tree2a64e8dd3a7ae7fc097e14bba432d71193c39c6f /cli/deno_error.rs
parentc920c5f62aba7eee0f6fa70f68f701e204ac1a9c (diff)
feat: Add support for passing a key to Deno.env() (#2952)
This adds a new op to get a single env var.
Diffstat (limited to 'cli/deno_error.rs')
-rw-r--r--cli/deno_error.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/deno_error.rs b/cli/deno_error.rs
index eb885adb8..551547e26 100644
--- a/cli/deno_error.rs
+++ b/cli/deno_error.rs
@@ -11,6 +11,7 @@ use hyper;
use reqwest;
use rustyline::error::ReadlineError;
use std;
+use std::env::VarError;
use std::error::Error;
use std::fmt;
use std::io;
@@ -136,6 +137,16 @@ impl GetErrorKind for ModuleResolutionError {
}
}
+impl GetErrorKind for VarError {
+ fn kind(&self) -> ErrorKind {
+ use VarError::*;
+ match self {
+ NotPresent => ErrorKind::NotFound,
+ NotUnicode(..) => ErrorKind::InvalidData,
+ }
+ }
+}
+
impl GetErrorKind for io::Error {
fn kind(&self) -> ErrorKind {
use io::ErrorKind::*;
@@ -294,6 +305,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::<VarError>().map(Get::kind))
.or_else(|| self.downcast_ref::<ReadlineError>().map(Get::kind))
.or_else(|| {
self