Skip to content

Add CompatForm::logAndShowError() - #393

Merged
lippserd merged 3 commits into
mainfrom
feature/log-form-errors
Jul 1, 2026
Merged

Add CompatForm::logAndShowError()#393
lippserd merged 3 commits into
mainfrom
feature/log-form-errors

Conversation

@jrauh01

@jrauh01 jrauh01 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Subclasses that catch an exception or otherwise fail during processing previously had to repeat the same three steps by hand:

  1. log the error
  2. add it as a form message
  3. call onError() to mark the form as failed

logAndShowError() bundles this into one call.

Exceptions are logged with their confidential stack trace (argument values redacted, types only) via IcingaException::getConfidentialTraceAsString(), so call sites don't need to worry about leaking sensitive data into the log. Plain strings and Stringable messages are logged as-is.

Subclasses that catch an exception or otherwise fail during processing
previously had to repeat the same three steps by hand:

1. log the error
2. add it as a form message
3. call `onError()` to mark the form as failed

`logAndShowError()` bundles this into one call.

Exceptions are logged with their confidential stack trace (argument values
redacted, types only) via `IcingaException::getConfidentialTraceAsString()`,
so call sites don't need to worry about leaking sensitive data into the log.
Plain strings and `Stringable` messages are logged as-is.
@jrauh01

jrauh01 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Tests for this are currently not possible due to our test structure. I've added them in #394 so we can add them later. I verified locally that the tests were successful.

@jrauh01 jrauh01 added this to the 0.14.0 milestone Jul 1, 2026
jrauh01 added 2 commits July 1, 2026 14:11
`logAndShowError()` now replaces `{error}` in the template itself and forwards
any extra `$args` to `Form::addMessage()` for the remaining formatting.
@lippserd
lippserd merged commit f7df38d into main Jul 1, 2026
14 checks passed
@lippserd
lippserd deleted the feature/log-form-errors branch July 1, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants