1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
denoland-deno/cli/ops/errors.rs

31 lines
776 B
Rust
Raw Normal View History

// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2020-09-05 20:34:02 -04:00
use crate::diagnostics::Diagnostics;
use crate::fmt_errors::format_file_name;
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::Extension;
pub fn init() -> Extension {
Extension::builder()
.ops(vec![
op_format_diagnostic::decl(),
op_format_file_name::decl(),
])
.build()
}
#[op]
2022-03-15 19:33:46 -04:00
fn op_format_diagnostic(args: Value) -> Result<Value, AnyError> {
let diagnostic: Diagnostics = serde_json::from_value(args)?;
Ok(json!(diagnostic.to_string()))
}
#[op]
2022-03-15 19:33:46 -04:00
fn op_format_file_name(file_name: String) -> Result<String, AnyError> {
Ok(format_file_name(&file_name))
}