1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 01:59:06 -05:00

Better exception output.

This commit is contained in:
Ryan Dahl 2018-07-16 23:25:50 -04:00
parent 3e51605bc9
commit b892188878
5 changed files with 16 additions and 9 deletions

View file

@ -24,7 +24,10 @@ config("deno_config") {
rust_executable("deno") {
source_root = "src/main.rs"
extern = [ "$rust_build:libc" ]
extern = [
"$rust_build:libc",
"$rust_build:log",
]
deps = [
":libdeno",
]
@ -35,7 +38,10 @@ rust_executable("deno") {
# extra process of building a snapshot and instead load the bundle from disk.
rust_executable("deno_nosnapshot") {
source_root = "src/main.rs"
extern = [ "$rust_build:libc" ]
extern = [
"$rust_build:libc",
"$rust_build:log",
]
deps = [
":libdeno_nosnapshot",
]

View file

@ -36,7 +36,7 @@ window.onerror = (
// Error.prepareStackTrace handler. Users will get unmapped stack traces on
// uncaught exceptions until this issue is fixed.
//Error.prepareStackTrace = null;
console.log(error.message, error.stack);
console.log(error.stack);
os.exit(1);
};

View file

@ -15,9 +15,9 @@ export function log(...args: any[]): void {
}
}
export function assert(cond: boolean, msg = "") {
export function assert(cond: boolean, msg = "assert") {
if (!cond) {
throw Error(`Assert fail. ${msg}`);
throw Error(msg);
}
}

View file

@ -177,9 +177,6 @@ pub extern "C" fn handle_code_fetch(
module_specifier_: *const c_char,
containing_file_: *const c_char,
) {
// TODO(ry) Move this to main.
log::set_max_level(log::LevelFilter::Debug);
let module_specifier = string_from_ptr(module_specifier_);
let containing_file = string_from_ptr(containing_file_);

View file

@ -1,4 +1,6 @@
extern crate libc;
#[macro_use]
extern crate log;
use libc::c_char;
use libc::c_int;
@ -107,6 +109,8 @@ impl Drop for Deno {
}
fn main() {
log::set_max_level(log::LevelFilter::Debug);
unsafe { deno_init() };
set_flags();
@ -122,7 +126,7 @@ fn main() {
d.execute("deno_main.js", "denoMain();")
.unwrap_or_else(|err| {
println!("Error {}\n", err);
error!("{}", err);
std::process::exit(1);
});
}