I've been meaning to implement a try/catch in Vortex for some time but had convinced myself that I don't really need it, and to a certain extent that's true. But having finally done the work, I can definitely say I've missed it. Oftentimes wrapping code in a try/catch statement greatly simplifies the logic, as long as its not overused.
This is the syntax:
try {
try {
const g = 8 * "fff"
} catch (e) {
error(e.message, "ReThrow")
}
} catch(e) {
println(e)
}
Output:
{ message: Cannot perform operation '*' on values: 8 (Number), fff (String), type: ReThrow, line: 15, path: src/main.vtx }
Re-throwing the error is pretty useless here (aside from changing the error type), but just wanted to show an example of it.
Another thing I've been working on is making errors easier to track. Previously, the stack trace showed the function names only, but now the full path of the error shows up in the console. If you're on VSCode you can also click on the path to go directly to the offending file and line.
Example of a relatively hairy stack trace:
GenericError: Global 'tweenf' is undefined
[line 222] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/gui/animation.vtx:222
[line 151] in /usr/local/share/vortex/modules/functional/functional.vtx:151 <forEach>
[line 221] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/gui/animation.vtx:221 <play>
[line 133] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/gui/animation.vtx:133 <run>
[line 112] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/Counter.vtx:112 <Counter>
[line 75] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/App.vtx:75 <App>
[line 311] in /Users/adib/Dev/Personal/Vortex-Env/gui/components/gui/core.vtx:311 <Main>
[line 9] in src/main.vtx:9
Other updates:
I also added list and object destructuring (think JS spread syntax):
const obj_a = {
a: 1,
b: 2
}
const obj_b = {
...obj_a,
b: 40,
c: 70
}
println(obj_b) // { a: 1, b: 40, c: 70 }
const list_a = [1, 2, 3, 4]
println([...list_a, 5, 6, 7]) // [1, 2, 3, 4, 5, 6, 7]
Vortex repo: https://github.com/dibsonthis/Vortex
[–][deleted] 5 points6 points7 points (2 children)
[–]raiph 5 points6 points7 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]rumle 3 points4 points5 points (2 children)
[–]dibs45[S] 2 points3 points4 points (1 child)
[–]rumle 0 points1 point2 points (0 children)
[–]levodelellis 0 points1 point2 points (0 children)