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

Annotation for replacing errorHandler? #506

Closed
jonkeane opened this issue Jan 10, 2020 · 1 comment
Closed

Annotation for replacing errorHandler? #506

jonkeane opened this issue Jan 10, 2020 · 1 comment

Comments

@jonkeane
Copy link

First, let me start off by saying thank you for an awesome flexible package for deploying APIs using R.

I see in the docs that one can set a custom error handler using something like (wherecustom_error_handler is a function that handles errors as they come up, similar to the defaultErrorHandler used by Plumber) :

r <- plumb("plumber_api.R")
r$setErrorHandler(custom_error_handler)
r$run()

This works great and I was able to get my custom error handling working well. However, I didn't see (in the docs or source) a way to use an annotation like one can for creating serializers or filters for defining a custom error handler for an app.

I've forked the repo, and created a working proof of concept for adding this which was based off of how filters and serializers were implemented. I've also tested this locally and publishing an API to RStudio Connect that includes and uses custom error handling (which is the use case I was looking for the errorhandling annotation for).

I'm happy to submit this as a PR if this approach is reasonable (after I add bit more checking for e.g. that only one errorhandler is provided).

@schloerke
Copy link
Collaborator

Closing via #507 (comment)

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

No branches or pull requests

2 participants