quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Control the content of error attributes

Open aoudiamoncef opened this issue 2 years ago • 4 comments

Description

There is an interesting feature in Spring Boot which controls easily error attributes.

Default configuration:

server:
  error:
    include-stacktrace: never
    include-message: never
    include-binding-errors: never
    include-exception: off

ErrorAttributeOptions could be reused easily in custom application configuration properties

I saw exception-mapping

Implementation ideas

Implementation -> BasicErrorController

To see it in action:

  1. generate a simple Spring Boot project with this link

  2. create a GET endpoint /boom which throws an exception

  3. call /boom and see the response(properties includes/excludes)

  4. tweak server configuration:

server:
  error:
    include-stacktrace: always
    include-message: always
  1. check returned response if it includes message + stacktrace

Thanks

aoudiamoncef avatar Apr 29 '22 15:04 aoudiamoncef

It s a good idea in cases we have large amount of logs.

Erfankam avatar Aug 30 '22 06:08 Erfankam

/cc @FroMage, @geoand, @stuartwdouglas

quarkus-bot[bot] avatar Oct 07 '22 07:10 quarkus-bot[bot]

This indeed seems like an interesting feature. Do you know how widely used it is in Spring Boot?

geoand avatar Oct 07 '22 07:10 geoand

Seems interesting. Related (a bit) to #13662.

FroMage avatar Oct 12 '22 13:10 FroMage