Ver 1.6 - Where is the exception stack trace gone?

For extended error reporting, I handle errors like this:

Procedure LogException(E : Exception;....)
Var S  : String;
Begin
 ...
 ASM
  if (E.FJSError===undefined)
   var stack = E.stack.toString().split(/\r\n|\n/);
  else
   var stack = E.FJSError.stack.toString().split(/\r\n|\n/);
  S = stack[1];
 END;
 // Do something with stack trace in S
End;

This is broken in 1.6. as E.stack resp. E.FJSError.stack no longer exists.

Where is the exception stack trace gone?

Regards, Walter

I investigated a little further and found out that the declaration of class Exception was changed in 1.6 in that the Javscript error object is no longer created.

Version 1.6 Exception class

Exception = class(TObject)
  private
    fMessage: String;
    ...
  Public
    constructor Create(const Msg: String); reintroduce;
    ...
  end;

constructor Exception.Create(const Msg: String);
begin
  fMessage:=Msg;
  ...
end;

Previous version of Exception class

Exception = class(TObject)
  private
    fMessage: String;
    FJSError: TJSError;
    ...
  public
    constructor Create(const Msg: String); reintroduce;
    ...
    property JSError: TJSError read FJSError write FJSError;
    ...
  end;

constructor Exception.Create(const Msg: String);
begin
  fMessage:=Msg;
  FJSError := TJSError.new(Msg);
  ...
end;

The difference is that FJSError resp JSError no longer exists in 1.6.

Would you mind to explain why the JS error object is no longer created? This effectively also removes the callstack that comes with the JS error object and therefore breaks any error reporting relying on the callstack.

Thank you, regards, Walter

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

This is part of the pas2js RTL, so we will check this with the pas2js team what the rationale behind this is. It was changed between pas2js v1.4 and pas2js v2.0.

We checked with the pas2js team and we have fixed this regression. Next update will address this.