1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-19 19:55:30 +08:00
Commit Graph

14 Commits

Author SHA1 Message Date
Steven Hartland
9297a9abe4
feat: add github action tests and linting (#418)
Leverage github actions for tests and linting.

This includes fixing a bunch of issues highlighted by golangci
including:
* Dead code.
* Ineffectual assigns.
* Goto warnings.
* Nil return err.
* Reused literal strings.
* Test parameter order.

Also:
* Setup clog.
2021-09-27 16:19:28 +01:00
uppfinnarn
a87f62d034 Failing test for #202 2016-06-21 13:48:49 +02:00
deoxxa
c03dfd35cd support the non-standard Error.stack property
Popular runtimes (V8[1], SpiderMonkey[2], IE[3]) support a `stack`
property on Error objects to get the error's stack as a string.

This change adds support to otto for this same feature. It's implemented
in a similar way to V8, using a getter function. This avoids generating
the stack trace (which is done in a loop with string manipulation etc)
unless the user requests it. There's no standard, or even trend, for the
actual _content_ of `stack`, so we basically just copy what V8's traces
look like.

[1]: https://github.com/v8/v8/wiki/Stack%20Trace%20API
[2]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
[3]: http://msdn.microsoft.com/en-us/library/windows/apps/hh699850.aspx
2016-05-02 19:22:56 +10:00
deoxxa
a7e69fb1ca add error creator functions
This change adds a handful of functions to `otto.Otto` type that make
it easier to create proper `Error` values from native code. Previously,
the only way to do this was to call the error's constructor from
JavaScript like `vm.Call("TypeError", "message")`. `Call` can fail for
various reasons, and also modifies the current call stack.

These new functions can't fail, and since they don't involve any
JavaScript execution, won't modify the call stack. The new functions
are:

* `MakeCustomError(name, message string) Value`
* `MakeRangeError(message string) Value`
* `MakeSyntaxError(message string) Value`
* `MakeTypeError(message string) Value`

`MakeCustomError` creates an `Error` object with a specific `name` value.
The other functions cover some common error types, and call specific
functions in the runtime to construct errors with the correct prototypes.
If we need to implement any other error types, it'll mostly be copy/paste.
2016-04-30 12:45:33 +10:00
Dmitry Panov
9d3cca217b Fixed error position for "Cannot access member '%s' of %s" 2015-04-04 14:27:24 +01:00
Dmitry Panov
1e5ee63535 Fixed stacktrace positions. 2015-04-01 21:03:24 +01:00
Robert Krimen
ed456945de Improve error reporting (again) 2014-06-21 21:16:58 -07:00
Robert Krimen
e6768252c2 Improve error reporting
* Delay entering global scope on code evaluation, not runtime creation

This fixes #66
2014-06-12 21:27:32 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
9561f66959 Tighten test comparisons instead of squashing everything to a string 2014-04-13 18:09:46 -07:00
Robert Krimen
baf3318f30 Add Error.prototype.message 2013-06-02 15:03:33 -07:00
Robert Krimen
83c56dd73d Add Otto.Call 2013-05-19 19:03:05 -07:00
Robert Krimen
e2e79bb697 A Value panic during a FunctionCall is the same as a throw in JavaScript 2013-05-19 15:54:10 -07:00
Robert Krimen
2642607a58 Fix HasInstance to recurse the prototype hierarchy 2013-04-20 20:03:34 -07:00