@@ -4045,46 +4045,7 @@ public RaiseException newStandardError(String message) {
4045
4045
* TODO: Should we include this into Errno code somewhere do we can use this from other places as well?
4046
4046
*/
4047
4047
public RaiseException newIOErrorFromException (final IOException ex ) {
4048
- final String errorMessage = ex .getMessage ();
4049
- if ( errorMessage != null ) {
4050
- // All errors to sysread should be SystemCallErrors, but on a closed stream
4051
- // Ruby returns an IOError. Java throws same exception for all errors so
4052
- // we resort to this hack...
4053
- switch ( errorMessage ) {
4054
- case "Bad file descriptor" :
4055
- if ( ex instanceof ClosedChannelException ) throw newErrnoEBADFError ();
4056
- break ;
4057
- case "File not open" :
4058
- return newIOError (errorMessage );
4059
- case "An established connection was aborted by the software in your host machine" :
4060
- return newErrnoECONNABORTEDError ();
4061
- case "Broken pipe" :
4062
- return newErrnoEPIPEError ();
4063
- case "Connection reset by peer" :
4064
- case "An existing connection was forcibly closed by the remote host" :
4065
- return newErrnoECONNRESETError ();
4066
- case "Too many levels of symbolic links" :
4067
- return newErrnoELOOPError ();
4068
- case "Too many open files" :
4069
- return newErrnoEMFILEError ();
4070
- case "Too many open files in system" :
4071
- return newErrnoENFILEError ();
4072
- case "Network is unreachable" :
4073
- return newErrnoENETUNREACHError ();
4074
- case "Address already in use" :
4075
- return newErrnoEADDRINUSEError ();
4076
- default :
4077
- if ( Platform .IS_WINDOWS ) {
4078
- if ( errorMessage .contains ("connection was aborted" ) ) {
4079
- return newErrnoECONNRESETError ();
4080
- }
4081
- }
4082
- }
4083
- return newRaiseException (getIOError (), errorMessage );
4084
- } else if (ex instanceof PortUnreachableException ) {
4085
- throw newErrnoECONNREFUSEDError ();
4086
- }
4087
- return newRaiseException (getIOError (), "IO Error" );
4048
+ return Helpers .newIOErrorFromException (this , ex );
4088
4049
}
4089
4050
4090
4051
public RaiseException newTypeError (IRubyObject receivedObject , RubyClass expectedType ) {
0 commit comments