Remove the the Extra line of an Exception [closed]

I want to print only the first line this below exception and the other lines started with ‘at’ want to remove.

org.springframework.boot.json.JsonParseException: Cannot parse JSON
            at org.springframework.boot.json.AbstractJsonParser.tryParse(AbstractJsonParser.java:57)

            at org.springframework.boot.json.JacksonJsonParser.parseMap(JacksonJsonParser.java:56)

            at com.dish.wireless.rm.common.config.CustomHeaderResponseFilterHandler.doFilterInternal(CustomHeaderResponseFilterHandler.java:96)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

  • 1

    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it’s currently written, it’s hard to tell exactly what you’re asking.

    – 
    Bot

  • 2

    Sounds like you only want to print e.getMessage()?

    – 




  • I don’t want the body. The line which are starting with ‘at’ I don’t want those line to print.

    – 

  • 1

    Just you e.getMessage() or e.getLocalizedMessage() to get only the error message, not the entire error trace

    – 

  • If you don’t want the stack trace, don’t use printStackTrace()

    – 

Leave a Comment