Browse Source

* Add Error.Message

Michaël Van Canneyt 1 year ago
parent
commit
73867e47f9
1 changed files with 12 additions and 1 deletions
  1. 12 1
      packages/wasm-job/src/job.js.pas

+ 12 - 1
packages/wasm-job/src/job.js.pas

@@ -1080,13 +1080,17 @@ type
 
 
   IJSError = interface(IJSObject)
   IJSError = interface(IJSObject)
     ['{80532C4D-CAD2-4C70-A4EA-01B29BB8C2C8}']
     ['{80532C4D-CAD2-4C70-A4EA-01B29BB8C2C8}']
+    function _getMessage : String;
+    property Message : string Read _getMessage;
   end;
   end;
 
 
   { TJSError }
   { TJSError }
 
 
   TJSError = class(TJSObject,IJSError)
   TJSError = class(TJSObject,IJSError)
+    function _getMessage : String;
   public
   public
     class function Cast(const Intf: IJSObject): IJSError; overload;
     class function Cast(const Intf: IJSObject): IJSError; overload;
+    property Message : string Read _GetMessage;
   end;
   end;
 
 
   TJSPromiseResolver = function(const aValue: Variant): Variant of object;
   TJSPromiseResolver = function(const aValue: Variant): Variant of object;
@@ -1593,11 +1597,18 @@ end;
 
 
 { TJSError }
 { TJSError }
 
 
+function TJSError._getMessage: String;
+begin
+  Result:=ReadJSPropertyUnicodeString('message');
+end;
+
 class function TJSError.Cast(const Intf: IJSObject): IJSError;
 class function TJSError.Cast(const Intf: IJSObject): IJSError;
 begin
 begin
   Result:=TJSError.JOBCast(Intf);
   Result:=TJSError.JOBCast(Intf);
 end;
 end;
 
 
+
+
 { TJSJSON }
 { TJSJSON }
 
 
 function TJSJSON.parse(const aJSON: UnicodeString): TJOB_JSValue;
 function TJSJSON.parse(const aJSON: UnicodeString): TJOB_JSValue;
@@ -2056,7 +2067,7 @@ begin
         Exit(Round(TJOB_Double(V).Value));
         Exit(Round(TJOB_Double(V).Value));
     if V is TJOB_String then
     if V is TJOB_String then
       begin
       begin
-      if TryStrToInt(TJOB_STRING(V).Value,Result) then
+      if TryStrToInt64(TJOB_STRING(V).Value,Result) then
         Exit
         Exit
       end;
       end;
   finally
   finally