mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
8b31fc23cd
The following transformations gradually faced by "JsError" have all been moved up front to "JsError::from_v8_exception()": - finding the first non-"deno:" source line; - moving "JsError::script_resource_name" etc. into the first error stack in case of syntax errors; - source mapping "JsError::script_resource_name" etc. when wrapping the error even though the frame locations are source mapped earlier; - removing "JsError::{script_resource_name,line_number,start_column,end_column}" entirely in favour of "js_error.frames.get(0)". We also no longer pass a js-side callback to "core/02_error.js" from cli. I avoided doing this on previous occasions because the source map lookups were in an awkward place.
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
use crate::ops::runtime::ppid;
|
|
use deno_core::serde_json;
|
|
use deno_core::serde_json::json;
|
|
use deno_core::ModuleSpecifier;
|
|
|
|
/// Common bootstrap options for MainWorker & WebWorker
|
|
#[derive(Clone)]
|
|
pub struct BootstrapOptions {
|
|
/// Sets `Deno.args` in JS runtime.
|
|
pub args: Vec<String>,
|
|
pub cpu_count: usize,
|
|
pub debug_flag: bool,
|
|
pub enable_testing_features: bool,
|
|
pub location: Option<ModuleSpecifier>,
|
|
/// Sets `Deno.noColor` in JS runtime.
|
|
pub no_color: bool,
|
|
pub is_tty: bool,
|
|
/// Sets `Deno.version.deno` in JS runtime.
|
|
pub runtime_version: String,
|
|
/// Sets `Deno.version.typescript` in JS runtime.
|
|
pub ts_version: String,
|
|
pub unstable: bool,
|
|
}
|
|
|
|
impl BootstrapOptions {
|
|
pub fn as_json(&self) -> String {
|
|
let payload = json!({
|
|
// Shared bootstrap args
|
|
"args": self.args,
|
|
"cpuCount": self.cpu_count,
|
|
"debugFlag": self.debug_flag,
|
|
"denoVersion": self.runtime_version,
|
|
"location": self.location,
|
|
"noColor": self.no_color,
|
|
"isTty": self.is_tty,
|
|
"tsVersion": self.ts_version,
|
|
"unstableFlag": self.unstable,
|
|
// Web worker only
|
|
"enableTestingFeaturesFlag": self.enable_testing_features,
|
|
// Env values
|
|
"pid": std::process::id(),
|
|
"ppid": ppid(),
|
|
"target": env!("TARGET"),
|
|
"v8Version": deno_core::v8_version(),
|
|
});
|
|
serde_json::to_string_pretty(&payload).unwrap()
|
|
}
|
|
}
|