Skip to content

Commit

Permalink
Make this use strerror to get the errno message
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 9, 2024
1 parent a84bc99 commit 7f9166a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -3838,10 +3838,17 @@ public RaiseException newErrnoETIMEDOUTError() {
}

public RaiseException newErrnoFromLastPOSIXErrno() {
RubyClass errnoClass = getErrno(getPosix().errno());
if (errnoClass == null) errnoClass = systemCallError;
String message = null;
int errno = getPosix().errno();
RubyClass errnoClass = getErrno(errno);
if (errnoClass == null) {
errnoClass = systemCallError;
} else {
message = getPosix().strerror(errno);
}


return newRaiseException(errnoClass, null);
return newRaiseException(errnoClass, message);
}

public RaiseException newErrnoFromInt(int errno, String methodName, String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ public interface LibC {
int getsockopt(int s, int level, int optname, @Out ByteBuffer optval, @Out IntByReference optlen);
int setsockopt(int s, int level, int optname, @In ByteBuffer optval, int optlen);
int setsockopt(int s, int level, int optname, @In Timeval optval, int optlen);
String strerror(int error);
}

static final LibC SOCKOPT;
Expand Down

0 comments on commit 7f9166a

Please sign in to comment.