-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement advanced java exception handling using liblognorm error callback #18
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments about tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Noticed an error in liblognorm documentations on how the pure json format should be constructed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New changes look good.
23d2d2c
to
a52ce97
Compare
Rebased to main |
Added exception test for partially invalid rulebase. |
…ackImpl.java. Renamed tests.
…. Removed now obsolete LogMessageMatcher.java.
…mplesJsonCallbackExceptionTest() to loadSamplesJsonTest(). REBASE
8c84421
to
534facc
Compare
Rebased to main |
|
||
@Override | ||
public void invoke(Pointer cookie, String msg, int length) { | ||
LOGGER.debug("liblognorm: {}", msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use "<{}>", msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in commit 9e0e25d
@Override | ||
public void invoke(Pointer cookie, String msg, int length) { | ||
errors.add(msg); | ||
LOGGER.error("liblognorm error: {}", msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use "<{}>", msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in commit 9e0e25d
* Method for throwing any received liblognorm error messages as java exception. | ||
*/ | ||
public void throwOccurredErrors() { | ||
if (!errors.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should thrown errors be cleared or are they always so fatal that the object instance is invalid after some occured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rulebase loading method for liblognorm will not return error codes when the rulebase has errors in it, instead it will generate error messages and return 0 indicating that the loading of the rulebase was successful.
By implementing the check for error messages those rulebase errors can be caught as java exceptions.
In my opinion the errors should be handled using fail fast, making the object instance invalid if they occur.
Includes:
Also includes commits from PR #14. Rebase may be needed in this PR after they have been merged to main.
New commits are cf2b6e6 and later.