rexyai / RestRserve

R web API framework for building high-performance microservices and app backends
https://restrserve.org
275 stars 32 forks source link

Raise expetions in process_request #79

Closed artemklevtsov closed 4 years ago

artemklevtsov commented 5 years ago

process_request not catches some exceptions. For example raise from the ContentHandlers$get_decode. May be anywhere else. As result Rserve raise it own HTTP status (500) and body (500 Evaluation error).

dselivanov commented 5 years ago

Working on it

artemklevtsov commented 5 years ago

Nice. However post my first draft.

      # capture raise HTTPError and early stop
      decoder = try(self$ContentHandlers$get_decode(request$content_type), silent = TRUE)
      if (inherits(encoder, "try-error")) {
        response = attr(decoder, "condition")$response
        return(response$to_rserve())
      }
      request$decode = decoder
artemklevtsov commented 5 years ago

Also if request body is empty we don't do it.