mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
Do not convert exceptions to JSON and back (#4214)
This commit is contained in:
parent
3fcbf8789e
commit
eafd40feab
14 changed files with 280 additions and 764 deletions
|
@ -1,7 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
use super::dispatch_json::{Deserialize, JsonOp, Value};
|
||||
use crate::diagnostics::Diagnostic;
|
||||
use crate::fmt_errors::JSError;
|
||||
use crate::op_error::OpError;
|
||||
use crate::source_maps::get_orig_position;
|
||||
use crate::source_maps::CachedMaps;
|
||||
|
@ -14,32 +13,12 @@ pub fn init(i: &mut Isolate, s: &State) {
|
|||
"op_apply_source_map",
|
||||
s.stateful_json_op(op_apply_source_map),
|
||||
);
|
||||
i.register_op("op_format_error", s.stateful_json_op(op_format_error));
|
||||
i.register_op(
|
||||
"op_format_diagnostic",
|
||||
s.stateful_json_op(op_format_diagnostic),
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct FormatErrorArgs {
|
||||
error: String,
|
||||
}
|
||||
|
||||
fn op_format_error(
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError> {
|
||||
let args: FormatErrorArgs = serde_json::from_value(args)?;
|
||||
let error =
|
||||
JSError::from_json(&args.error, &state.borrow().global_state.ts_compiler);
|
||||
|
||||
Ok(JsonOp::Sync(json!({
|
||||
"error": error.to_string(),
|
||||
})))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ApplySourceMap {
|
||||
filename: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue