All Projects → rustwasm → Console_error_panic_hook

rustwasm / Console_error_panic_hook

Licence: other
A panic hook for wasm32-unknown-unknown that logs panics with console.error

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Console error panic hook

Rs Asteroids
A variation on the game Asteroids, written in Rust
Stars: ✭ 146 (-8.18%)
Mutual labels:  wasm
Go Logger
一个简单而强大的 golang 日志工具包,支持同步和异步输出到 命令行,文件, api 接口,文件支持按文件大小,文件行数,日期切分;A simple and powerful golang logging toolkit that supports synchronous and asynchronous output to the console, file, API interfaces, file support by file size, file line number, date sharding.
Stars: ✭ 152 (-4.4%)
Mutual labels:  console
Dotnet Console Games
Game examples implemented in .NET console applications primarily for educational purposes.
Stars: ✭ 157 (-1.26%)
Mutual labels:  console
Python Sploitkit
Devkit for building Metasploit-like consoles
Stars: ✭ 148 (-6.92%)
Mutual labels:  console
Deno Sqlite
Deno SQLite module
Stars: ✭ 151 (-5.03%)
Mutual labels:  wasm
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: ✭ 1,906 (+1098.74%)
Mutual labels:  console
Hexed
Windows console-based hex editor
Stars: ✭ 145 (-8.81%)
Mutual labels:  console
Brainfuck
Collection of BF interpreters/translators in C/C++/ASM/JS/Python/Rust + others
Stars: ✭ 157 (-1.26%)
Mutual labels:  wasm
Wasmer Java
☕ WebAssembly runtime for Java
Stars: ✭ 152 (-4.4%)
Mutual labels:  wasm
Blazor Samples
Explore and learn Syncfusion Blazor components using large collection of demos, example applications and tutorial samples
Stars: ✭ 156 (-1.89%)
Mutual labels:  wasm
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (-8.81%)
Mutual labels:  wasm
Spec
WebAssembly for Proxies (ABI specification)
Stars: ✭ 150 (-5.66%)
Mutual labels:  wasm
Seed
A Rust framework for creating web apps
Stars: ✭ 3,069 (+1830.19%)
Mutual labels:  wasm
Wasm Crypto
A WebAssembly (via AssemblyScript) set of cryptographic primitives for building authentication and key exchange protocols.
Stars: ✭ 146 (-8.18%)
Mutual labels:  wasm
Uno.quickstart
An Uno "Hello world!" project using Windows UWP, iOS, Android and WebAssembly
Stars: ✭ 157 (-1.26%)
Mutual labels:  wasm
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+8171.7%)
Mutual labels:  wasm
Clog
Package clog is a channel-based logging package for Go
Stars: ✭ 151 (-5.03%)
Mutual labels:  console
Consoletableext
A fluent library to print out a nicely formatted table in a console application C#
Stars: ✭ 158 (-0.63%)
Mutual labels:  console
Emberclear
Encrypted Chat. No History. No Logs.
Stars: ✭ 157 (-1.26%)
Mutual labels:  wasm
Package Builder
[READ-ONLY] Speed up your package DI containers integration and console apps to Symfony and Nette
Stars: ✭ 152 (-4.4%)
Mutual labels:  console

console_error_panic_hook

Build Status

This crate lets you debug panics on wasm32-unknown-unknown by providing a panic hook that forwards panic messages to console.error.

When an error is reported with console.error, browser devtools and node.js will typically capture a stack trace and display it with the logged error message.

Without console_error_panic_hook you just get something like RuntimeError: Unreachable executed

Browser: Console without panic hook

Node: Node console without panic hook

With this panic hook installed you will see the panic message

Browser: Console with panic hook set up

Node: Node console with panic hook set up

Usage

There are two ways to install this panic hook.

First, you can set the hook yourself by calling std::panic::set_hook in some initialization function:

extern crate console_error_panic_hook;
use std::panic;

fn my_init_function() {
    panic::set_hook(Box::new(console_error_panic_hook::hook));

    // ...
}

Alternatively, use set_once on some common code path to ensure that set_hook is called, but only the one time. Under the hood, this uses std::sync::Once.

extern crate console_error_panic_hook;

struct MyBigThing;

impl MyBigThing {
    pub fn new() -> MyBigThing {
        console_error_panic_hook::set_once();

        MyBigThing
    }
}

Error.stackTraceLimit

Many browsers only capture the top 10 frames of a stack trace. In rust programs this is less likely to be enough. To see more frames, you can set the non-standard value Error.stackTraceLimit. For more information see the MDN Web Docs or v8 docs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].