Replace RuntimeException with OwnLangRuntimeException in modules

This commit is contained in:
aNNiMON 2023-10-05 19:11:34 +03:00 committed by Victor Melnik
parent d3dd8feb10
commit e304aafedd
17 changed files with 70 additions and 50 deletions

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.date; package com.annimon.ownlang.modules.date;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.exceptions.TypeException; import com.annimon.ownlang.exceptions.TypeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module; import com.annimon.ownlang.modules.Module;
@ -274,7 +275,7 @@ public final class date implements Module {
try { try {
return DateValue.from(format.parse(args[0].asString())); return DateValue.from(format.parse(args[0].asString()));
} catch (ParseException ex) { } catch (ParseException ex) {
throw new RuntimeException(ex); throw new OwnLangRuntimeException(ex);
} }
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.forms; package com.annimon.ownlang.modules.forms;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import static com.annimon.ownlang.lib.Converters.*; import static com.annimon.ownlang.lib.Converters.*;
import com.annimon.ownlang.lib.FunctionValue; import com.annimon.ownlang.lib.FunctionValue;
@ -55,7 +56,7 @@ public class JTextAreaValue extends JTextComponentValue {
int result = f.accept(args[0].asInt()); int result = f.accept(args[0].asInt());
return NumberValue.of(result); return NumberValue.of(result);
} catch (BadLocationException ex) { } catch (BadLocationException ex) {
throw new RuntimeException(ex); throw new OwnLangRuntimeException(ex);
} }
}); });
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.gzip; package com.annimon.ownlang.modules.gzip;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.exceptions.TypeException; import com.annimon.ownlang.exceptions.TypeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module; import com.annimon.ownlang.modules.Module;
@ -45,7 +46,7 @@ public class gzip implements Module {
gzos.finish(); gzos.finish();
return NumberValue.ONE; return NumberValue.ONE;
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("gzipFile", ex); throw new OwnLangRuntimeException("gzipFile", ex);
} }
} }
@ -63,7 +64,7 @@ public class gzip implements Module {
gzos.finish(); gzos.finish();
return ArrayValue.of(baos.toByteArray()); return ArrayValue.of(baos.toByteArray());
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("gzipBytes", ex); throw new OwnLangRuntimeException("gzipBytes", ex);
} }
} }
@ -85,7 +86,7 @@ public class gzip implements Module {
copy(gzis, os); copy(gzis, os);
return NumberValue.ONE; return NumberValue.ONE;
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("ungzipFile", ex); throw new OwnLangRuntimeException("ungzipFile", ex);
} }
} }
@ -102,7 +103,7 @@ public class gzip implements Module {
copy(gzis, baos); copy(gzis, baos);
return ArrayValue.of(baos.toByteArray()); return ArrayValue.of(baos.toByteArray());
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("ungzipBytes", ex); throw new OwnLangRuntimeException("ungzipBytes", ex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.java; package com.annimon.ownlang.modules.java;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module; import com.annimon.ownlang.modules.Module;
import java.lang.reflect.Array; import java.lang.reflect.Array;
@ -245,7 +246,7 @@ public final class java implements Module {
try { try {
return new ClassValue(Class.forName(className)); return new ClassValue(Class.forName(className));
} catch (ClassNotFoundException ce) { } catch (ClassNotFoundException ce) {
throw new RuntimeException("Class " + className + " not found.", ce); throw new OwnLangRuntimeException("Class " + className + " not found.", ce);
} }
} }
@ -307,7 +308,7 @@ public final class java implements Module {
// skip // skip
} }
} }
throw new RuntimeException("Constructor for " + args.length + " arguments" throw new OwnLangRuntimeException("Constructor for " + args.length + " arguments"
+ " not found or non accessible"); + " not found or non accessible");
} }
@ -327,7 +328,7 @@ public final class java implements Module {
} }
} }
final String className = (object == null ? "null" : object.getClass().getName()); final String className = (object == null ? "null" : object.getClass().getName());
throw new RuntimeException("Method for " + args.length + " arguments" throw new OwnLangRuntimeException("Method for " + args.length + " arguments"
+ " not found or non accessible in " + className); + " not found or non accessible in " + className);
}; };
} }

View File

@ -1,6 +1,7 @@
package com.annimon.ownlang.modules.jdbc; package com.annimon.ownlang.modules.jdbc;
import com.annimon.ownlang.exceptions.ArgumentsMismatchException; import com.annimon.ownlang.exceptions.ArgumentsMismatchException;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module; import com.annimon.ownlang.modules.Module;
import java.io.IOException; import java.io.IOException;
@ -99,7 +100,7 @@ public final class jdbc implements Module {
throw new ArgumentsMismatchException("Wrong number of arguments"); throw new ArgumentsMismatchException("Wrong number of arguments");
} }
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new OwnLangRuntimeException(ex);
} }
}; };
} }
@ -161,7 +162,7 @@ public final class jdbc implements Module {
throw new ArgumentsMismatchException("Wrong number of arguments"); throw new ArgumentsMismatchException("Wrong number of arguments");
} }
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -186,7 +187,7 @@ public final class jdbc implements Module {
throw new ArgumentsMismatchException("Wrong number of arguments"); throw new ArgumentsMismatchException("Wrong number of arguments");
} }
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -284,7 +285,7 @@ public final class jdbc implements Module {
try { try {
return new URL(args[1].asString()); return new URL(args[1].asString());
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new OwnLangRuntimeException(ioe);
} }
})); }));
} }
@ -298,7 +299,7 @@ public final class jdbc implements Module {
else statement.addBatch(args[0].asString()); else statement.addBatch(args[0].asString());
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -316,7 +317,7 @@ public final class jdbc implements Module {
(String[] columnNames) -> statement.execute(sql, columnNames)); (String[] columnNames) -> statement.execute(sql, columnNames));
return NumberValue.fromBoolean(result); return NumberValue.fromBoolean(result);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -345,7 +346,7 @@ public final class jdbc implements Module {
(String[] columnNames) -> statement.executeUpdate(sql, columnNames)); (String[] columnNames) -> statement.executeUpdate(sql, columnNames));
return NumberValue.of(rowCount); return NumberValue.of(rowCount);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -363,7 +364,7 @@ public final class jdbc implements Module {
(String[] columnNames) -> statement.executeLargeUpdate(sql, columnNames)); (String[] columnNames) -> statement.executeLargeUpdate(sql, columnNames));
return NumberValue.of(rowCount); return NumberValue.of(rowCount);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
} }
@ -463,7 +464,7 @@ public final class jdbc implements Module {
try { try {
return NumberValue.of(rs.findColumn(args[0].asString())); return NumberValue.of(rs.findColumn(args[0].asString()));
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -476,7 +477,7 @@ public final class jdbc implements Module {
rs.updateNull(args[0].asString()); rs.updateNull(args[0].asString());
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
} }
@ -514,7 +515,7 @@ public final class jdbc implements Module {
return columnNamesFunction.apply(columnNames); return columnNamesFunction.apply(columnNames);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }
@ -539,7 +540,7 @@ public final class jdbc implements Module {
result.execute(); result.execute();
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -551,7 +552,7 @@ public final class jdbc implements Module {
result.execute(args[0].asInt()); result.execute(args[0].asInt());
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -561,7 +562,7 @@ public final class jdbc implements Module {
try { try {
return NumberValue.fromBoolean(result.get()); return NumberValue.fromBoolean(result.get());
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -571,7 +572,7 @@ public final class jdbc implements Module {
try { try {
return NumberValue.of(numberResult.get()); return NumberValue.of(numberResult.get());
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -581,7 +582,7 @@ public final class jdbc implements Module {
try { try {
return new StringValue(stringResult.get()); return new StringValue(stringResult.get());
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -591,7 +592,7 @@ public final class jdbc implements Module {
try { try {
return converter.apply(objectResult.get()); return converter.apply(objectResult.get());
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -606,7 +607,7 @@ public final class jdbc implements Module {
} }
return NumberValue.fromBoolean(stringResult.get(args[0].asString())); return NumberValue.fromBoolean(stringResult.get(args[0].asString()));
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -620,7 +621,7 @@ public final class jdbc implements Module {
} }
return NumberValue.of(stringResult.get(args[0].asString())); return NumberValue.of(stringResult.get(args[0].asString()));
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -634,7 +635,7 @@ public final class jdbc implements Module {
} }
return new StringValue(stringResult.get(args[0].asString())); return new StringValue(stringResult.get(args[0].asString()));
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -649,7 +650,7 @@ public final class jdbc implements Module {
} }
return converter.apply(stringResult.get(args[0].asString())); return converter.apply(stringResult.get(args[0].asString()));
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -664,7 +665,7 @@ public final class jdbc implements Module {
} }
return converter.apply(stringResult.get(args[0].asString()), args); return converter.apply(stringResult.get(args[0].asString()), args);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -676,7 +677,7 @@ public final class jdbc implements Module {
result.execute(converter.apply(args)); result.execute(converter.apply(args));
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -688,7 +689,7 @@ public final class jdbc implements Module {
numberResult.execute(args[0].asInt(), converter.apply(args)); numberResult.execute(args[0].asInt(), converter.apply(args));
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -705,7 +706,7 @@ public final class jdbc implements Module {
} }
return NumberValue.ONE; return NumberValue.ONE;
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
}); });
} }
@ -728,7 +729,7 @@ public final class jdbc implements Module {
} }
return new ResultSetValue(result); return new ResultSetValue(result);
} catch (SQLException sqlex) { } catch (SQLException sqlex) {
throw new RuntimeException(sqlex); throw new OwnLangRuntimeException(sqlex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.json; package com.annimon.ownlang.modules.json;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.Function; import com.annimon.ownlang.lib.Function;
import com.annimon.ownlang.lib.Value; import com.annimon.ownlang.lib.Value;
@ -17,7 +18,7 @@ public final class json_decode implements Function {
final Object root = new JSONTokener(jsonRaw).nextValue(); final Object root = new JSONTokener(jsonRaw).nextValue();
return ValueUtils.toValue(root); return ValueUtils.toValue(root);
} catch (JSONException ex) { } catch (JSONException ex) {
throw new RuntimeException("Error while parsing json", ex); throw new OwnLangRuntimeException("Error while parsing json", ex);
} }
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.json; package com.annimon.ownlang.modules.json;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.ArrayValue; import com.annimon.ownlang.lib.ArrayValue;
import com.annimon.ownlang.lib.Function; import com.annimon.ownlang.lib.Function;
@ -36,7 +37,7 @@ public final class json_encode implements Function {
return new StringValue(jsonRaw); return new StringValue(jsonRaw);
} catch (JSONException ex) { } catch (JSONException ex) {
throw new RuntimeException("Error while creating json", ex); throw new OwnLangRuntimeException("Error while creating json", ex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.okhttp; package com.annimon.ownlang.modules.okhttp;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.Converters; import com.annimon.ownlang.lib.Converters;
import com.annimon.ownlang.lib.Function; import com.annimon.ownlang.lib.Function;
@ -56,7 +57,7 @@ public class CallValue extends MapValue {
try { try {
return new ResponseValue(call.execute()); return new ResponseValue(call.execute());
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new OwnLangRuntimeException(e);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package com.annimon.ownlang.modules.okhttp; package com.annimon.ownlang.modules.okhttp;
import com.annimon.ownlang.Console; import com.annimon.ownlang.Console;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.ArrayValue; import com.annimon.ownlang.lib.ArrayValue;
import com.annimon.ownlang.lib.Converters; import com.annimon.ownlang.lib.Converters;
@ -27,7 +28,7 @@ public class ResponseBodyValue extends MapValue {
try { try {
return ArrayValue.of(responseBody.bytes()); return ArrayValue.of(responseBody.bytes());
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new OwnLangRuntimeException(e);
} }
}); });
set("close", Converters.voidToVoid(responseBody::close)); set("close", Converters.voidToVoid(responseBody::close));
@ -37,7 +38,7 @@ public class ResponseBodyValue extends MapValue {
try { try {
return new StringValue(responseBody.string()); return new StringValue(responseBody.string());
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new OwnLangRuntimeException(e);
} }
}); });
set("file", args -> { set("file", args -> {
@ -48,7 +49,7 @@ public class ResponseBodyValue extends MapValue {
sink.close(); sink.close();
return NumberValue.ONE; return NumberValue.ONE;
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new OwnLangRuntimeException(e);
} }
}); });
} }

View File

@ -72,7 +72,7 @@ public final class robot implements Module {
awtRobot = new Robot(); awtRobot = new Robot();
return true; return true;
} catch (AWTException awte) { } catch (AWTException awte) {
//throw new RuntimeException("Unable to create robot instance", awte); //throw new OwnLangRuntimeException("Unable to create robot instance", awte);
return false; return false;
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.std; package com.annimon.ownlang.modules.std;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.exceptions.TypeException; import com.annimon.ownlang.exceptions.TypeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.ArrayValue; import com.annimon.ownlang.lib.ArrayValue;
@ -23,7 +24,7 @@ public final class ArrayFunctions {
try { try {
return new StringValue(new String(bytes, charset)); return new StringValue(new String(bytes, charset));
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
throw new RuntimeException(uee); throw new OwnLangRuntimeException(uee);
} }
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.std; package com.annimon.ownlang.modules.std;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.ArrayValue; import com.annimon.ownlang.lib.ArrayValue;
import com.annimon.ownlang.lib.NumberValue; import com.annimon.ownlang.lib.NumberValue;
@ -17,7 +18,7 @@ public final class StringFunctions {
try { try {
return ArrayValue.of(args[0].asString().getBytes(charset)); return ArrayValue.of(args[0].asString().getBytes(charset));
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
throw new RuntimeException(uee); throw new OwnLangRuntimeException(uee);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.std; package com.annimon.ownlang.modules.std;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.Arguments; import com.annimon.ownlang.lib.Arguments;
import com.annimon.ownlang.lib.Function; import com.annimon.ownlang.lib.Function;
import com.annimon.ownlang.lib.FunctionValue; import com.annimon.ownlang.lib.FunctionValue;
@ -31,7 +32,7 @@ public final class std_sync implements Function {
return queue.take(); return queue.take();
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException(ex); throw new OwnLangRuntimeException(ex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.yaml; package com.annimon.ownlang.modules.yaml;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -21,7 +22,7 @@ public final class yaml_decode implements Function {
final Object root = new Yaml(options).load(yamlRaw); final Object root = new Yaml(options).load(yamlRaw);
return process(root); return process(root);
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException("Error while parsing yaml", ex); throw new OwnLangRuntimeException("Error while parsing yaml", ex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.yaml; package com.annimon.ownlang.modules.yaml;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -22,7 +23,7 @@ public final class yaml_encode implements Function {
final String yamlRaw = new Yaml(options).dump(root); final String yamlRaw = new Yaml(options).dump(root);
return new StringValue(yamlRaw); return new StringValue(yamlRaw);
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException("Error while creating yaml", ex); throw new OwnLangRuntimeException("Error while creating yaml", ex);
} }
} }

View File

@ -1,5 +1,6 @@
package com.annimon.ownlang.modules.zip; package com.annimon.ownlang.modules.zip;
import com.annimon.ownlang.exceptions.OwnLangRuntimeException;
import com.annimon.ownlang.exceptions.TypeException; import com.annimon.ownlang.exceptions.TypeException;
import com.annimon.ownlang.lib.*; import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module; import com.annimon.ownlang.modules.Module;
@ -98,7 +99,7 @@ public class zip implements Module {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("zip files", ex); throw new OwnLangRuntimeException("zip files", ex);
} }
return NumberValue.of(count); return NumberValue.of(count);
} }
@ -193,7 +194,7 @@ public class zip implements Module {
} }
zis.closeEntry(); zis.closeEntry();
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("unzip files", ex); throw new OwnLangRuntimeException("unzip files", ex);
} }
return NumberValue.of(count); return NumberValue.of(count);
} }
@ -261,7 +262,7 @@ public class zip implements Module {
} }
zis.closeEntry(); zis.closeEntry();
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("list zip entries", ex); throw new OwnLangRuntimeException("list zip entries", ex);
} }
return entries.toArray(new String[0]); return entries.toArray(new String[0]);
} }

View File

@ -15,6 +15,11 @@ public class OwnLangRuntimeException extends RuntimeException implements SourceL
this.range = null; this.range = null;
} }
public OwnLangRuntimeException(Exception ex) {
super(ex);
this.range = null;
}
public OwnLangRuntimeException(String message) { public OwnLangRuntimeException(String message) {
this(message, (Range) null); this(message, (Range) null);
} }