Skip to content

Commit

Permalink
Handle EADDRNOTAVAIL as a BaseConnectionError
Browse files Browse the repository at this point in the history
instead of letting EADDRNOTAVAIL be handled as a generic SyscallError convert it to a BaseConnectionError
instead, in this case we treat it as a a TRILOGY_DNS_ERROR
so that the activerecord adapters handle it as a DBConnectionError.
  • Loading branch information
dhruvCW committed Jul 10, 2023
1 parent 640f990 commit bcf974b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contrib/ruby/ext/trilogy-ruby/cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ static void trilogy_syserr_fail_str(int e, VALUE msg)
rb_raise(Trilogy_ConnectionRefusedError, "%" PRIsVALUE, msg);
} else if (e == ECONNRESET) {
rb_raise(Trilogy_ConnectionResetError, "%" PRIsVALUE, msg);
} else if (e == EADDRNOTAVAIL) {
rb_raise(Trilogy_BaseConnectionError, "%" PRIsVALUE ": TRILOGY_DNS_ERROR", msg);
} else {
VALUE exc = rb_funcall(Trilogy_SyscallError, id_from_errno, 2, INT2NUM(e), msg);
rb_exc_raise(exc);
Expand Down

0 comments on commit bcf974b

Please sign in to comment.