Skip to content
  • Yorick Peterse's avatar
    Add support for registering panic handlers · 5e6920e3
    Yorick Peterse authored
    A panic handler is a block to execute when a process panics. Once the
    block finishes running, the process terminates. A panic handler can be
    registered using `std::process.panicking`:
    
        import std::process
        import std::stdio::stderr
        import std::vm
    
        process.panicking do (error) {
          stderr.print(error)
        }
    
        vm.panic('oops!')
    
    Each process can only register a single panic handler, and newly
    registered handlers will overwrite any previous ones.
    
    The block passed to `std::process.panicking` is given the panic message.
    A stacktrace needs to be obtained manually using
    `std::debug.stacktrace`.
    5e6920e3