Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errors package with optional stacktrace capturing #431

Merged
merged 1 commit into from
Aug 22, 2021

Commits on Aug 21, 2021

  1. Add errors package with optional stacktrace capturing

    The goal of this package is to enable to capture stack traces when the error are being raised, which speeds up the development process, if enabled at compile time. To do so, this set of changes introduces an internal/errors package to handle errors with four functions: .New, .Errorf, .Is and .Unwrap. Albeit support for reflect has been added recently to tinygo, it presently not depend on reflect in any way.
    
    If the code is compiled with the debug build tag, the stack trace will be captured when an error is created or wrapped (both with .New). Without that build tag, the errors packages falls back to simply comparing values and performs no wrapping at all.
    
    It also come with a new testutil/assert package which replaces the require package when it comes to checking or comparing errors and printing the stack traces if needed.
    
    Finally, the test target of the Makefile uses the debug build tag by default. A testnodebug target is also provided for convenience and to make sure no tests breaks due to not having used the internal/errors or testutil/assert package.
    jhchabran committed Aug 21, 2021
    Configuration menu
    Copy the full SHA
    442c4df View commit details
    Browse the repository at this point in the history