Skip to content

Conversation

tnleeuw
Copy link
Contributor

@tnleeuw tnleeuw commented May 14, 2025

Adding a DataSonnetErrorMessageFormatter will come in a follow-up PR, to keep the changes smaller.

@tnleeuw tnleeuw self-assigned this May 14, 2025
@tnleeuw tnleeuw marked this pull request as ready for review May 15, 2025 08:45
@tnleeuw tnleeuw requested review from nielsm5 and evandongen May 15, 2025 08:45

@Override
@Protected
public void setMessageFormat(@Nonnull DocumentFormat messageFormat) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waarom override je deze method hier en in de XslErrorMessageFormatter? Het doet precies hetzelfde als in de super.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Om de @Protected annotatie toe te voegen, die voorkomt dat de setter in de Frank!Doc komt en via Configuration gezet kan worden.

Ik had geen comment toegevoegd omdat ik dacht dat het uit de annotatie duidelijk zou moeten zijn, maar zal een kort comment toevoegen. :-)

tnleeuw and others added 2 commits May 15, 2025 11:10
…rrorMessageFormatter.java

Co-authored-by: Erik <dongenevan@gmail.com>
@tnleeuw tnleeuw linked an issue May 15, 2025 that may be closed by this pull request
@tnleeuw tnleeuw requested a review from evandongen May 15, 2025 13:23
assertNotNull(errorAsString);

String expected = """
<errorMessage timestamp="Wed May 14 16:26:41 CEST 2025" originator="IAF " message="MyLocation [dummy-location] msgId [dummy-message-id]: dummy-error-message">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik heb liever dat hier de ignores hard in staan, dan is de replace minder foutgevoelig...

@Protected
public void setMessageFormat(@Nonnull DocumentFormat messageFormat) {
// Add no logic, override to add @Protected annotation which will make sure this method cannot be used from configuration for this class
super.setMessageFormat(messageFormat);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventueel kan je hier een exceptie gooien, notimplementedexception oid.

@Protected
public void setMessageFormat(@Nonnull DocumentFormat messageFormat) {
// Add no logic, override to add @Protected annotation which will make sure this method cannot be used from configuration for this class
super.setMessageFormat(messageFormat);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventueel kan je hier een exceptie gooien, notimplementedexception oid.

tnleeuw added 3 commits May 15, 2025 17:43
# Conflicts:
#	core/src/main/java/org/frankframework/errormessageformatters/ErrorMessageFormatter.java
#	core/src/main/java/org/frankframework/errormessageformatters/SoapErrorMessageFormatter.java
#	nn-specials/src/main/java/org/frankframework/errormessageformatters/Y01ErrorMessageFormatter.java
Copy link

@tnleeuw tnleeuw requested a review from nielsm5 May 16, 2025 08:42
@tnleeuw
Copy link
Contributor Author

tnleeuw commented May 16, 2025

Ik zie dat Sonar en Codacy een issue hebben met het gooien van RuntimeException; daar had ik al iets aan gedaan maar in mijn PR voor de DataSonnetErrorFormatter dus dat komt later goed. 😃

}
errorObject.addAttribute("timestamp", new Date().toString());
errorObject.addAttribute("originator", originator);
errorObject.addAttribute("message", XmlEncodingUtils.replaceNonValidXmlCharacters(errorMessage));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In de SaxElementBuilder#addAttribute(String, String) zit ook al een replace xml ding dacht ik. Misschien kan deze wel weg :)

if (t != null) {
e.addSuppressed(t);
}
throw new RuntimeException("Cannot create formatted error message for error [" + errorMessage + "]", e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poeh, ik weet niet of ik runtime wel zo mooi vind...

@tnleeuw tnleeuw merged commit 99fc070 into master May 16, 2025
32 of 33 checks passed
@tnleeuw tnleeuw deleted the feature/8976_AddJsonErrorMessageFormatter branch May 16, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format errors as JSON data instead of XML
3 participants