summaryrefslogtreecommitdiff
path: root/cli/ops/idna.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-08-07 22:47:18 +0200
committerGitHub <noreply@github.com>2020-08-07 16:47:18 -0400
commit59ca66a207ceb4699e1322ce22f953ac0f124f13 (patch)
tree775b30b9a46f3c824d97060fb147336ecb6b83b7 /cli/ops/idna.rs
parent479164d287604d079f6342e656f2ac95b109367f (diff)
Encode op errors as strings instead of numbers (#6977)
Diffstat (limited to 'cli/ops/idna.rs')
-rw-r--r--cli/ops/idna.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/cli/ops/idna.rs b/cli/ops/idna.rs
index 8ecef4862..ee78307dc 100644
--- a/cli/ops/idna.rs
+++ b/cli/ops/idna.rs
@@ -3,7 +3,7 @@
//! https://url.spec.whatwg.org/#idna
use super::dispatch_json::{Deserialize, JsonOp, Value};
-use crate::op_error::{ErrorKind, OpError};
+use crate::op_error::OpError;
use crate::state::State;
use deno_core::CoreIsolate;
use deno_core::ZeroCopyBuf;
@@ -13,13 +13,6 @@ pub fn init(i: &mut CoreIsolate, s: &State) {
i.register_op("op_domain_to_ascii", s.stateful_json_op(op_domain_to_ascii));
}
-fn invalid_domain_error() -> OpError {
- OpError {
- kind: ErrorKind::TypeError,
- msg: "Invalid domain.".to_string(),
- }
-}
-
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct DomainToAscii {
@@ -35,9 +28,10 @@ fn op_domain_to_ascii(
let args: DomainToAscii = serde_json::from_value(args)?;
let domain = if args.be_strict {
domain_to_ascii_strict(args.domain.as_str())
- .map_err(|_| invalid_domain_error())?
+ .map_err(|_| OpError::invalid_domain_error())?
} else {
- domain_to_ascii(args.domain.as_str()).map_err(|_| invalid_domain_error())?
+ domain_to_ascii(args.domain.as_str())
+ .map_err(|_| OpError::invalid_domain_error())?
};
Ok(JsonOp::Sync(json!(domain)))
}