activeresource icon indicating copy to clipboard operation
activeresource copied to clipboard

Raise ActiveResource::ConnectionRefusedError on Errno::ECONNREFUSED

Open balvig opened this issue 2 years ago • 2 comments

What

Raises a custom ActiveResource::ConnectionError when failing to connect to an external endpoint completely, changing something like:

Errno::ECONNREFUSED: Failed to open TCP connection to 127.0.0.1:4568 (Connection refused - connect(2) for "127.0.0.1" port 4568)

...into:

ActiveResource::ConnectionRefusedError: Failed to open TCP connection to 127.0.0.1:4568 (Connection refused - connect(2) for "127.0.0.1" port 4568)

Why

Follows the convention of rescuing network errors and wrapping them in ActiveResource custom errors, allowing them to be rescued without leaking knowledge of internals.

balvig avatar Dec 12 '23 01:12 balvig

This is a behavior change. If people are already rescuing ECONNREFUSED they would now get error in production. Can we do it without breaking existing code?

rafaelfranca avatar Jan 24 '24 20:01 rafaelfranca

Cheers, good shout @rafaelfranca!

The only thing that immediately comes to mind is having the custom exception inherit from ECONNREFUSED rather than ConnectionError.

The lack of parity with the other custom exceptions feels a little off, but it might be worth it to avoid a breaking change? Am I otherwise missing something? 🤔

balvig avatar Jan 29 '24 05:01 balvig