From 3c1a0ad19e7b044bb40f979ec4c5f81bf39dec4b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 13 Jan 2019 22:14:59 -0500 Subject: Properly parse network addresses. (#1515) --- src/errors.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/errors.rs') diff --git a/src/errors.rs b/src/errors.rs index f16ba6299..55185df8e 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,9 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use hyper; + pub use msg::ErrorKind; +use resolve_addr::ResolveAddrError; + +use hyper; use std; use std::fmt; use std::io; @@ -149,6 +152,22 @@ impl From for DenoError { } } +impl From for DenoError { + fn from(e: ResolveAddrError) -> Self { + match e { + ResolveAddrError::Syntax => Self { + repr: Repr::Simple( + ErrorKind::InvalidInput, + "invalid address syntax".to_string(), + ), + }, + ResolveAddrError::Resolution(io_err) => Self { + repr: Repr::IoErr(io_err), + }, + } + } +} + pub fn bad_resource() -> DenoError { new(ErrorKind::BadResource, String::from("bad resource id")) } -- cgit v1.2.3