Skip to content
Commit 5dca0d2e authored by Jonathan Poelen's avatar Jonathan Poelen
Browse files

Show call stack when there is an error in js script

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
```
parent 9e683652
Pipeline #346533 passed with stage
in 8 minutes and 29 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment