Fix crash when toString returns null value (#8067)
* Fix crash when toString returns null value * Return a string from NullUnit toString * Begone redundancy * Unwrap before null check to ensure non-nullability
This commit is contained in:
@@ -45,8 +45,10 @@ public class Scripts implements Disposable{
|
||||
try{
|
||||
Object o = context.evaluateString(scope, text, "console.js", 1);
|
||||
if(o instanceof NativeJavaObject n) o = n.unwrap();
|
||||
if(o instanceof Undefined) o = "undefined";
|
||||
return String.valueOf(o);
|
||||
if(o == null) o = "null";
|
||||
else if(o instanceof Undefined) o = "undefined";
|
||||
var out = o.toString();
|
||||
return out == null ? "null" : out;
|
||||
}catch(Throwable t){
|
||||
return getError(t, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user