Skip to content

Allow for custom error message during BARF recovery #18

@Folakuku

Description

@Folakuku

Either directly pass a RecoveryMessage or pass a RecoveryHandler, a function that gives you access to the panic error, manipulate it as needed, maybe even send an alert somewhere and then return a response string that's sent as the server response.

Here's sample use case

        // create server
	if err := barf.Stark(barf.Augment{
		Logging:        barf.Allow(), // enable request logging
		Recovery:       barf.Allow(), // enable panic recovery so barf returns a 500 error instead of crashing
                RecoveryHandler: func (err error) string {
                        return err.String() 
                },
                RecoveryMessage: "Something went wrong",
	}); err != nil {
		barf.Logger().Error(err.Error())
		os.Exit(1)
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions