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

Enable propogation of fatal errors through io.Reader responses #504

Open
bmoffatt opened this issue Apr 19, 2023 · 0 comments
Open

Enable propogation of fatal errors through io.Reader responses #504

bmoffatt opened this issue Apr 19, 2023 · 0 comments
Assignees
Labels

Comments

@bmoffatt
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

A handler can gracefully force the process to be restarted by returning a messages.InvokeResponse_Error with ShouldExit = true. The usual way this happens is when the function panics, but pass-through is allowed too on the handler's error value

if ive, ok := invokeError.(messages.InvokeResponse_Error); ok {
return &ive
}

However, there's not an equivalent when the response value is a reader.

Describe the solution you'd like

Goal should be able to make this:

type fatalReader struct{}
func (r *fatalReader) Read(_ []byte) (int, error) {
  return 0, messages.InvokeResponse_Error{Type: "IDK", Message: "fatal", ShouldExit: true}
}
func handler() (any, error) {
  return fatalReader{}, nil
}

result in the same logging and error reporting as this:

func hander() (any, error) {
  return nil, messages.InvokeResponse_Error{Type: "IDK", Message: "fatal", ShouldExit: true}
}

Describe alternatives you've considered

Might also expose something like

func lambdaPanicResponse(err interface{}) *messages.InvokeResponse_Error {
if ive, ok := err.(messages.InvokeResponse_Error); ok {
return &ive
}
panicInfo := getPanicInfo(err)
return &messages.InvokeResponse_Error{
Message: panicInfo.Message,
Type: getErrorType(err),
StackTrace: panicInfo.StackTrace,
ShouldExit: true,
}
}
in the public API, to make the construction of these fatal errors easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant