Skip to content
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

Add log-ready information to HermesResponse #808

Closed
rzarajczyk opened this issue Aug 14, 2017 · 5 comments
Closed

Add log-ready information to HermesResponse #808

rzarajczyk opened this issue Aug 14, 2017 · 5 comments
Assignees

Comments

@rzarajczyk
Copy link

When I'm using HermesClient for publishing events tu Hermes I have to use the following code:

if (!hermesResponse.isSuccess()) {
    throw SimpleLagerthaFeederPublisherException.create(hermesResponse);
}

Where:

public static SimpleLagerthaFeederPublisherException create(HermesResponse response) {
    StringBuilder message = new StringBuilder();
    message.append("Error during publishing to Hermes:\n");
    message.append(" - messageId: ").append(response.getMessageId()).append("\n");
    message.append(" - response HTTP status: ").append(response.getHttpStatus()).append("\n");
    message.append(" - response body: ").append(response.getBody()).append("\n");
    message.append(" - cause: ").append(response.getFailureCause().map(throwable -> throwable.getMessage()).orElse("null"));
    Optional<Throwable> cause = response.getFailureCause();
    if (cause.isPresent()) {
        return new SimpleLagerthaFeederPublisherException(message.toString(), cause.get());
    } else {
        return new SimpleLagerthaFeederPublisherException(message.toString());
    }
}

My goal is only to log all information in case of failure. I don't really case in what format. Since the HermesResponse contains many methods with potentially relevant information and exception is Optional - I have to use such a long method just to gather all of these information.

Please consider some of the following:

  • creating toString() method which would contain problem description in case of problems
  • creating throwIfExceptionOccured() which could be use just to throw some exception in case of using HermesClient in synchronous way
  • adding javadoc wich would describe the dependencies between fields: f.ex. that if isSuccess() returns false, then getFailureCause() will never be empty (right now I have no idea if I can safely throw getFailureCause().get())
@mictyd
Copy link
Contributor

mictyd commented Oct 19, 2018

I'd like to work on it :)

@mictyd
Copy link
Contributor

mictyd commented Oct 19, 2018

adding javadoc wich would describe the dependencies between fields: f.ex. that if isSuccess() returns false, then getFailureCause() will never be empty (right now I have no idea if I can safely throw getFailureCause().get())

From what I know, isSuccess() may be false and getFailureCause() still not be present (e.g. when topic doesn't exist Hermes returns 404 - this may not cause an exception). I might add appropriate JavaDoc

mictyd added a commit to mictyd/hermes that referenced this issue Oct 19, 2018
@druminski
Copy link
Contributor

This issue is still active if someone would like to address it it will be great.

@TheTerabit
Copy link

I'd like to take care of it.

@druminski
Copy link
Contributor

Closing this issue as @mictyd added getDebugLog() to get relevant information when publish was unsuccessful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants