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.

ExceptionMapper ignores defaultContentType

See original GitHub issue

Consider the following snippet: Javalin app = Javalin.create().defaultContentType("application/json").start(); app.get("/", ctx -> { throw new ForbiddenResponse(); }); The defaultContentType is sent to the client, but the answer is in text/plain. Is this intended? If not, I would consider a little fix to io.javalin.core.util.HttpResponseExceptionMapper in the method handleException change if (ctx.header(Header.ACCEPT)?.contains("application/json") == true) to something like if (ctx.header(Header.ACCEPT)?.contains("application/json") || ctx.res.contentType.equals("application/json"))

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
maxemann96commented, Oct 24, 2018

So, @Playacem thx 😃

0reactions
tipsycommented, Oct 24, 2018

@maxemann96 thank @Playacem, he fixed it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jersey ignores ExceptionMapper - Stack Overflow
I made an ExceptionMapper to catch and log all exceptions, like: @Provider public class CatchAllExceptionsMapper implements ...
Read more >
RESTEasy JAX-RS - JBoss.org
This exception wraps all exceptions thrown from application code. It functions much in the same way as InvocationTargetException. If there is an ExceptionMapper...
Read more >
Red Hat JBoss Enterprise Application Platform 7.1
MessageBodyReaders, Writers, ContextResolvers, and ExceptionMappers. ... modify-wsdl-address is set to false this element is ignored. wsdl-port.
Read more >
Release Notes - Jersey 2.0 - GitHub Pages
[JERSEY-920] - The ExceptionMapper is not handled in ... [JERSEY-1511] - MessageBodyReader does not set default content-type; [JERSEY-1513] ...
Read more >
Spring Portlet MVC - Unable to return JSON data ... - GitHub
public void setDefaultContentType(MediaType defaultContentType) ... getName().contains(exceptionMapping)) { // Found it! return depth; } ...
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