Skip to content

Commit

Permalink
feat: console.error panic hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtieFuzzz committed Dec 11, 2022
1 parent 2617484 commit 4dd65a9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
Expand All @@ -15,3 +18,5 @@ opt-level = "s"
[dependencies]
worker = "0.0.12"

# Ease of Debugging
console_error_panic_hook = { version = "0.1.1", optional = true }
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use console_error_panic_hook::set_once as set_panic_hook;
use worker::*;

#[event(fetch)]
pub async fn main(req: Request, env: Env, _context: Context) -> Result<Response> {
set_console_error_hook();

let router = Router::new();

router
.get("/", |_, _| Response::ok("owo"))
.run(req, env)
.await
}

fn set_console_error_hook() {
set_panic_hook()
}

0 comments on commit 4dd65a9

Please sign in to comment.