Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Include original exception in new exception in on_communication_failure #13

Description

@dentarg

At https://github.com/twingly/ecco/blob/v0.5.0/lib/ecco/lifecycle_failure_listener.rb#L9-L12 we get an exception from Java, and create a new Ruby exception which we return to the user with the message from the old exception.

Often the message is nil, so it would be useful to also include the original exception, to help the user understand what's going on.

Like Ruby does since 2.1 with Exception Causes.

Activity

  1. roback commented on May 4, 2018

    @roback
    Member

    Not sure how we should solve this. There is no Exception#cause= method. We could implement our own on the error classes, but would be nice if there was a way to avoid that :)

    Some related comments: https://bugs.ruby-lang.org/issues/8257#note-32

  2. walro commented on May 4, 2018

    @walro
    Contributor

    Ah yes, we could tweak the error message instead possibly. Like:

    message = "#{exception.get_name}: #{exception.get_message)"
    error = Ecco::Error::CommunicationError.new(message)

    I think Sequel does something like this when wrapping, say, PostgreSQL errors.

  3. dentarg commented on May 4, 2018

    @dentarg
    ContributorAuthor

    We could implement our own on the error classes

    I was thinking that.

  4. walro commented on May 4, 2018

    @walro
    Contributor
  5. walro commented on May 4, 2018

    @walro
    Contributor

    A downside with wrap could be that we, possibly, don't want to pass on Java objects to the end users. Kind of what we want to avoid with #26

  6. dentarg commented on May 4, 2018

    @dentarg
    ContributorAuthor

    True, maybe we should just extract all info there is to our own Ruby exception

    The API doesn't look that big: https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html

  7. dentarg commented on May 4, 2018

    @dentarg
    ContributorAuthor

    Interesting issue about Java and Ruby exceptions: jruby/jruby#4781

  8. walro commented on May 4, 2018

    @walro
    Contributor

    we could do two passes:

    1. just include the class name (as suggested in Include original exception in new exception in on_communication_failure #13 (comment)) (this would close this issue)
    2. error super object with stuff like orignal stacktrace and what not (new issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions