From 45308e6d65527f3d815993c4731f8944c5adf29b Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 23 Nov 2024 20:04:03 +0200 Subject: [PATCH] refactor: remove periods from ends of error msgs --- .../java/me/topchetoeu/jscript/common/json/JSON.java | 2 +- .../topchetoeu/jscript/common/json/JSONElement.java | 12 ++++++------ .../me/topchetoeu/jscript/common/json/JSONMap.java | 10 +++++----- .../topchetoeu/jscript/common/parsing/ParseRes.java | 2 +- .../topchetoeu/jscript/common/parsing/Parsing.java | 4 ++-- .../java/me/topchetoeu/jscript/runtime/Compiler.java | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/common/json/JSON.java b/src/main/java/me/topchetoeu/jscript/common/json/JSON.java index 56c34c9..e5dcce0 100644 --- a/src/main/java/me/topchetoeu/jscript/common/json/JSON.java +++ b/src/main/java/me/topchetoeu/jscript/common/json/JSON.java @@ -102,7 +102,7 @@ public class JSON { if (filename == null) filename = new Filename("jscript", "json"); var res = parseValue(new Source(null, filename, raw), 0); - if (res.isFailed()) throw new SyntaxException(null, "Invalid JSON given."); + if (res.isFailed()) throw new SyntaxException(null, "Invalid JSON given"); else if (res.isError()) throw new SyntaxException(null, res.error); else return JSONElement.of(res.result); } diff --git a/src/main/java/me/topchetoeu/jscript/common/json/JSONElement.java b/src/main/java/me/topchetoeu/jscript/common/json/JSONElement.java index a8d8490..258497e 100644 --- a/src/main/java/me/topchetoeu/jscript/common/json/JSONElement.java +++ b/src/main/java/me/topchetoeu/jscript/common/json/JSONElement.java @@ -35,7 +35,7 @@ public class JSONElement { else if (val instanceof Boolean) return bool((Boolean)val); else if (val instanceof Number) return number(((Number)val).doubleValue()); else if (val == null) return NULL; - else throw new IllegalArgumentException("val must be: String, Boolean, Number, JSONList or JSONMap."); + else throw new IllegalArgumentException("val must be: String, Boolean, Number, JSONList or JSONMap"); } public final Type type; @@ -49,23 +49,23 @@ public class JSONElement { public boolean isNull() { return type == Type.NULL; } public JSONMap map() { - if (!isMap()) throw new IllegalStateException("Element is not a map."); + if (!isMap()) throw new IllegalStateException("Element is not a map"); return (JSONMap)value; } public JSONList list() { - if (!isList()) throw new IllegalStateException("Element is not a map."); + if (!isList()) throw new IllegalStateException("Element is not a map"); return (JSONList)value; } public String string() { - if (!isString()) throw new IllegalStateException("Element is not a string."); + if (!isString()) throw new IllegalStateException("Element is not a string"); return (String)value; } public double number() { - if (!isNumber()) throw new IllegalStateException("Element is not a number."); + if (!isNumber()) throw new IllegalStateException("Element is not a number"); return (double)value; } public boolean bool() { - if (!isBoolean()) throw new IllegalStateException("Element is not a boolean."); + if (!isBoolean()) throw new IllegalStateException("Element is not a boolean"); return (boolean)value; } diff --git a/src/main/java/me/topchetoeu/jscript/common/json/JSONMap.java b/src/main/java/me/topchetoeu/jscript/common/json/JSONMap.java index 2e2f1f9..2906910 100644 --- a/src/main/java/me/topchetoeu/jscript/common/json/JSONMap.java +++ b/src/main/java/me/topchetoeu/jscript/common/json/JSONMap.java @@ -51,7 +51,7 @@ public class JSONMap implements Map { public JSONMap map(String path) { var el = get(path); - if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist.", path)); + if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist", path)); return el.map(); } public JSONMap map(String path, JSONMap defaultVal) { @@ -63,7 +63,7 @@ public class JSONMap implements Map { public JSONList list(String path) { var el = get(path); - if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist.", path)); + if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist", path)); return el.list(); } public JSONList list(String path, JSONList defaultVal) { @@ -75,7 +75,7 @@ public class JSONMap implements Map { public String string(String path) { var el = get(path); - if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist.", path)); + if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist", path)); return el.string(); } public String string(String path, String defaultVal) { @@ -87,7 +87,7 @@ public class JSONMap implements Map { public double number(String path) { var el = get(path); - if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist.", path)); + if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist", path)); return el.number(); } public double number(String path, double defaultVal) { @@ -99,7 +99,7 @@ public class JSONMap implements Map { public boolean bool(String path) { var el = get(path); - if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist.", path)); + if (el == null) throw new RuntimeException(String.format("'%s' doesn't exist", path)); return el.bool(); } public boolean bool(String path, boolean defaultVal) { diff --git a/src/main/java/me/topchetoeu/jscript/common/parsing/ParseRes.java b/src/main/java/me/topchetoeu/jscript/common/parsing/ParseRes.java index 09b2c65..11502e8 100644 --- a/src/main/java/me/topchetoeu/jscript/common/parsing/ParseRes.java +++ b/src/main/java/me/topchetoeu/jscript/common/parsing/ParseRes.java @@ -34,7 +34,7 @@ public class ParseRes { return new ParseRes<>(state, null, null, result, this.n + n); } public ParseRes chainError() { - if (isSuccess()) throw new RuntimeException("Can't transform a ParseRes that hasn't failed."); + if (isSuccess()) throw new RuntimeException("Can't transform a ParseRes that hasn't failed"); return new ParseRes<>(state, errorLocation, error, null, 0); } @SuppressWarnings("unchecked") diff --git a/src/main/java/me/topchetoeu/jscript/common/parsing/Parsing.java b/src/main/java/me/topchetoeu/jscript/common/parsing/Parsing.java index fb5acc6..96886d8 100644 --- a/src/main/java/me/topchetoeu/jscript/common/parsing/Parsing.java +++ b/src/main/java/me/topchetoeu/jscript/common/parsing/Parsing.java @@ -86,10 +86,10 @@ public class Parsing { var newC = 0; for (var j = 0; j < 2; j++) { - if (i + n >= src.size()) return ParseRes.error(src.loc(i), "Invalid hexadecimal escape sequence."); + if (i + n >= src.size()) return ParseRes.error(src.loc(i), "Invalid hexadecimal escape sequence"); int val = fromHex(src.at(i + n)); - if (val == -1) throw new SyntaxException(src.loc(i + n), "Invalid hexadecimal escape sequence."); + if (val == -1) throw new SyntaxException(src.loc(i + n), "Invalid hexadecimal escape sequence"); n++; newC = (newC << 4) | val; diff --git a/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java b/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java index 526e646..42266dc 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java @@ -34,7 +34,7 @@ public interface Compiler { public static Compiler get(Environment ext) { return ext.get(KEY, (env, filename, src) -> { - throw EngineException.ofError("No compiler attached to engine."); + throw EngineException.ofError("No compiler attached to engine"); }); }