Skip to content

proposal: x/mobile: better support for unrecovered panics #70668

@xcolwell

Description

@xcolwell

Proposal Details

Currently with gomobile, the following example would crash the entire app with a single error message and no stack trace.

func HelloWorld() {
  var x *SomeType
  x.Foo()
  // oh no, the application crashed
}

In mobile applications we typically don't want to crash the app, but instead capture and report unrecovered errors and then handle the unrecovered errors as part of error handling in the caller. I'd like to propose four improvement to gomobile:

  1. Standard stack trace logging for all unrecovered errors.
  2. A global unrecovered error callback that is called before propagating unrecovered errors.
  3. Instead of unrecovered errors crashing the application, the error should be converted to an unchecked exception/fatal error type in the caller code so that it can integrate with the native unhandled error flow.
  4. Support for propagating unrecovered errors to the caller as checked exceptions. In many cases a typical return will be a pair of value and error, which is correctly translated to the exception framework by gomobile. Unrecovered errors would more naturally be "thrown" to the caller with the correct stack trace than crashing the application.

Is there a process to vet improvements like this before working on a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions