-
-
Save anonymous/5b101a92d8c2a3d4cb414140f882ebc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/src/main/java/org/jruby/Ruby.java b/core/src/main/java/org/jruby/Ruby.java | |
index ad2916b..4ef407c 100644 | |
--- a/core/src/main/java/org/jruby/Ruby.java | |
+++ b/core/src/main/java/org/jruby/Ruby.java | |
@@ -4080,6 +4080,8 @@ public final class Ruby implements Constantizable { | |
return newErrnoENFILEError(); | |
case "Network is unreachable" : | |
return newErrnoENETUNREACHError(); | |
+ case "Address already in use" : | |
+ return newErrnoEADDRINUSEError(); | |
default : | |
if ( Platform.IS_WINDOWS ) { | |
if ( errorMessage.contains("connection was aborted") ) { | |
diff --git a/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java b/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java | |
index b715160..3bc4851 100644 | |
--- a/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java | |
+++ b/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java | |
@@ -159,17 +159,13 @@ public class RubyUDPSocket extends RubyIPSocket { | |
catch (UnknownHostException e) { | |
throw SocketUtils.sockerr(runtime, "bind: name or service not known"); | |
} | |
- catch (SocketException e) { | |
- final String message = e.getMessage(); | |
- if ( message != null ) { | |
- switch ( message ) { | |
- case "Permission denied" : | |
- throw runtime.newErrnoEACCESError("bind(2) for " + host.inspect() + " port " + port); | |
- } | |
- } | |
- throw sockerr(runtime, "bind: name or service not known", e); | |
- } | |
catch (IOException e) { | |
+ RaiseException ioError = runtime.newIOErrorFromException(e); | |
+ if (ioError.getException().getMetaClass() != runtime.getIOError()) { | |
+ throw ioError; | |
+ } | |
+ | |
+ // could not find a specific exception, use SocketError | |
throw sockerr(runtime, "bind: name or service not known", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment