Skip to content

Add function to rethrow with a provided stacktrace. #30741

@lrhn

Description

@lrhn

Add a static rethrow method (with a different name since rethrow is reserved) that can synchronously throw an object and a stack trace. Currently there is no way to reuse an existing stack trace when throwing synchronously in a sync function, but you can do await new Future.error(object, stackTrace) in an async function. It's occasionally useful, and we have the functionality anyway (_rethrow in dart:async/zone.dart), so we should allow it in sync functions too.

Maybe as a static on Error: void Error.throwWithStack(Object error, [StackTrace stackTrace]); (maybe no need to make the stack trace optional, but it can then get the stackTrace from error if it implements Error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.core-llibrary-coretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions