Skip to content

Show call stack when there is an error in js script

Jonathan Poelen requested to merge work/show-js-context-on-error into master

It is very difficult to find the cause of an error with only the error message. This commit adds the javascript call stack in KateScript::backtrace() to display the file and line number involved.

  • When loading the file (SyntaxError)

Before:

Error loading script /home/jonathan/.local/share/katepart5/script/commands/xxx.js
:
SyntaxError: Unexpected token `numeric literal'

After:

Error loading script /home/jonathan/.local/share/katepart5/script/commands/xxx.js:
SyntaxError: Unexpected token `numeric literal'
Strack trace:
@file:///home/jonathan/.local/share/katepart5/script/commands/xxx.js:13
  • When executing a command

Before:

Error calling foo:
TypeError: Cannot call method 'myfunc' of undefined

After:

Error calling foo:
TypeError: Cannot call method 'myfunc' of undefined
Stack trace:
bar@file:///home/jonathan/.local/share/katepart5/script/commands/xxx.js:18
foo@file:///home/jonathan/.local/share/katepart5/script/commands/xxx.js:13

Merge request reports