summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-07-16 23:25:50 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-07-18 15:43:50 -0400
commitb892188878fd5a1a38a45d1c2e892c41be240ca0 (patch)
treed10a7023641c294a0c76f505c9ee0f870fdf36c9
parent3e51605bc9ca98522fc21a0673e690105f48da98 (diff)
Better exception output.
-rw-r--r--BUILD.gn10
-rw-r--r--js/runtime.ts2
-rw-r--r--js/util.ts4
-rw-r--r--src/handlers.rs3
-rw-r--r--src/main.rs6
5 files changed, 16 insertions, 9 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 33cb4f7bd..9c2fe5c1d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -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",
]
diff --git a/js/runtime.ts b/js/runtime.ts
index d234cdd85..c439fb963 100644
--- a/js/runtime.ts
+++ b/js/runtime.ts
@@ -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);
};
diff --git a/js/util.ts b/js/util.ts
index 7216f9491..05b243427 100644
--- a/js/util.ts
+++ b/js/util.ts
@@ -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);
}
}
diff --git a/src/handlers.rs b/src/handlers.rs
index 4c4a791ea..a9221a8cb 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -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_);
diff --git a/src/main.rs b/src/main.rs
index 10b1aef81..3af299428 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);
});
}