JavaScript Alerts

I am migrating business rules of Pascal Script to JavaScript, I want to know if there is any way to make JavaScript alerts are similar to Pascal Script alerts.
The javascript code shows me this line: “Script failed in beforePost (108/0)” before the message in my alert.

if((row[“CODIGO”] == null) || (Trim(row[“CODIGO”]) == “”))
{
errors = errors + “Código de artículo no puede estar vacio.”+"\n";
}

if(errors != “”)
{
fail(errors);
}

I need to be shown in this way:

if (VarisNull(CODIGO)) or (Trim(CODIGO)=’’) then
errors := errors + ‘Código de artículo no puede estar vacio.’+#13

if (errors <>’’) then
RaiseError(Errors);

You can raise proper exception via TDASpiderMonkeyScriptProvider.OnError event, something like:

procedure TDASampleService.EcmaScriptProviderError(
  aEcmaScriptProvider: TDABaseEcmaScriptProvider; aError: ScriptException);
var
  k: integer;
begin
  k := pos(') ',aError.Message);
  raise Exception.Create(Copy(aError.Message,k+2,MaxInt));
end;
1 Like

It works,thank you.