How to expose error and trace in Plumber?

I want to expose a full trace and error message from plumber instead of the generic {"error":["500 - Internal server error"]}

The documentation suggests I should be able to use setErrorHandler but not where that should be placed or what should be placed in it.

Referred here by plumber's GitHub

If your endpoint already returns JSON, the easiest way is to catch the error and return a JSON object that contains all the error info you need. something like:


  tryCatch(..., error = function(e) {
    res$status = 400  # the response object that is always available in plumber functions
    return(list(error = e, traceback = ...))

if your endpoint returns something else than JSON your out of luck (you can only have one serializer by endpoint). I don't think the ErrorHandler stuff works yet (or if it does, its not documented sufficiently)

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.