diff options
| author | Bert Belder <bertbelder@gmail.com> | 2020-08-26 00:22:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-26 00:22:15 +0200 |
| commit | 9bfb0df805719cb3f022a5b5d9f9d898ae954c2e (patch) | |
| tree | 6c7d62d95fcbde54ebbe1035bdc74618c63cfbc0 /cli/ops/idna.rs | |
| parent | d0ccab7fb7dd80030d3765ca9a9af44de6ecda5a (diff) | |
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/ops/idna.rs')
| -rw-r--r-- | cli/ops/idna.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cli/ops/idna.rs b/cli/ops/idna.rs index c76ceba89..9585e0977 100644 --- a/cli/ops/idna.rs +++ b/cli/ops/idna.rs @@ -3,9 +3,9 @@ //! https://url.spec.whatwg.org/#idna use super::dispatch_json::{Deserialize, JsonOp, Value}; -use crate::op_error::OpError; use crate::state::State; use deno_core::CoreIsolate; +use deno_core::ErrBox; use deno_core::ZeroCopyBuf; use idna::{domain_to_ascii, domain_to_ascii_strict}; use std::rc::Rc; @@ -25,14 +25,16 @@ fn op_domain_to_ascii( _state: &Rc<State>, args: Value, _zero_copy: &mut [ZeroCopyBuf], -) -> Result<JsonOp, OpError> { +) -> Result<JsonOp, ErrBox> { let args: DomainToAscii = serde_json::from_value(args)?; - let domain = if args.be_strict { + if args.be_strict { domain_to_ascii_strict(args.domain.as_str()) - .map_err(|_| OpError::invalid_domain_error())? } else { domain_to_ascii(args.domain.as_str()) - .map_err(|_| OpError::invalid_domain_error())? - }; - Ok(JsonOp::Sync(json!(domain))) + } + .map_err(|err| { + let message = format!("Invalid IDNA encoded domain name: {:?}", err); + ErrBox::new("URIError", message) + }) + .map(|domain| JsonOp::Sync(json!(domain))) } |
