# rescue **Repository Path**: mirrors_lestrrat-go/rescue ## Basic Information - **Project Name**: rescue - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-02 - **Last Updated**: 2025-12-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # rescue Aggregate errors/panics from goroutines ## Auto-capture panics (single goroutine) ```go func Foo(ctx context.Context) { defer rescue.Do(ctx) ... } r := rescue.New() go Foo(r.Context(ctx)) r.Wait() if err := r.Error(ctx); err != nil { ... handle panic ... } ``` ## Auto-capture errors (single goroutine) ```go func Foo(ctx context.Context) (err error){ rescue.Bind(ctx, &err) defer rescue.Do(ctx) ... } r := rescue.New() go Foo(r.Context(ctx)) r.Wait() if err := r.Error(ctx); err != nil { // Because this shares the interface panics, // we need to convert types switch err := err.(type) { case error: ... handle error ... default: ... handle panic ... } } ``` ## Capture errors and panics within multiple goroutines ```go func Foo(ctx context.Context) (err error){ rescue.Bind(ctx, &err) defer rescue.Do(ctx) ... } rg := rescue.NewGroup() for i := 0; i < 10; i++ { r := rg.New() go Foo(r.Context(ctx)) } rg.Wait() for err := rage rg.Errors() { // Because this shares the interface panics, // we need to convert types switch err := err.(type) { case error: ... handle error ... default: ... handle panic ... } }