Skip to content

Commit

Permalink
Better exception output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 18, 2018
1 parent 3e51605 commit b892188
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand All @@ -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",
]
Expand Down
2 changes: 1 addition & 1 deletion js/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
4 changes: 2 additions & 2 deletions js/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_);

Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
extern crate libc;
#[macro_use]
extern crate log;

use libc::c_char;
use libc::c_int;
Expand Down Expand Up @@ -107,6 +109,8 @@ impl Drop for Deno {
}

fn main() {
log::set_max_level(log::LevelFilter::Debug);

unsafe { deno_init() };

set_flags();
Expand All @@ -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);
});
}

0 comments on commit b892188

Please sign in to comment.