question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed outputs are rendered as responses with no body

See original GitHub issue

I’m trying to upgrade to 0.14 (from 0.11), and I’m encountering an issue with custom error responses. I am using finch-circe, and I have a custom Encoder[Exception] which is imported into the implicit scope where I’m calling toServiceAs, but I don’t see my custom output. Also, logging that I injected into my encoder never fires, which further indicates that my code is not getting run.

I see responses that look like:

HTTP/1.1 400 Bad Request
Content-Length: 0
Date: Fri, 21 Apr 2017 18:05:39 GMT
Vary: Origin

@vkostyukov notes that the date header means Finch is processing the response, because finagle by itself doesn’t have that. However, even if there was no message, the default Encoder[Exception] instance would seem to return "{message:null}" in the body, in the event of a missing message. It’s not clear why the bodies are missing entirely.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
rplesscommented, Oct 30, 2017

Hi @anatoliykmetyuk, it looks the rendering of the docs is a little messed up, but if you look at the bottom of this section, it shows that you can do this:

implicit val encodeExceptionCirce: Encoder[Exception] = 
  Encoder.instance(e =>	
    Json.obj(“message” -> Option(e.getMessage).fold(Json.Null)(Json.fromString)))

I’ll try to fix those up later so its clearer how to render errors.

0reactions
ComFreekcommented, Aug 1, 2020

Note that https://finagle.github.io/finch/user-guide.html#errors (that @rpless referenced above) contains a much more elaborated code snippet now than the comment above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cURL suppress response body - output - Stack Overflow
I want to examine the other parts of the output such as HTTP response code, headers, e.t.c. - everything except the actual HTML....
Read more >
Rendering Output - R Plumber
Renders the response object as a list containing status , headers , and body . The other methods ( clone , initialize ,...
Read more >
HTTPRequest node - IBM
The HTTPRequest node interacts with a web service, using all or part of the input message as the request that is sent to...
Read more >
Can I make cURL fail with an exitCode different than 0 if the ...
(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with...
Read more >
Handling missing inputs with req(...) - R Shiny
A primitive solution is to add precondition checks to all reactive expressions and outputs, and return NULL if any conditions are not met....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found