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

25 Commits

Author SHA1 Message Date
Steven Hartland
f76dda1760
feat: error with stack on %#v (#461)
Print the error with stack when using %#v.

Fixes #363
2022-11-27 23:12:50 +00:00
Steven Hartland
7009038f79
fix: linting errors (#441)
Disable new linters which aren't compatible with this code module.

Upgrade github actions to fix caching issues.

Run go mod to bring in new styling.

Remove space on nolint declarations.

Apply all changes to whitespace as required to pass goimports linter.

Only trigger checks on pull_request which works for pulls from other
forks, where as push only works from the same repo.
2022-10-08 00:12:19 +01:00
deoxxa
eb255cd1e9 implemet Function.caller 2017-10-03 09:46:37 +11:00
Alexander F Rødseth
ab54b0b8c6 Use -- instead of -= 1, as recommended by golint 2016-06-24 09:53:49 +02:00
uppfinnarn
cb827c7f40 Fix for #202 2016-06-21 13:49:50 +02:00
deoxxa
ccf93984d9 implement configurable stack trace limit 2016-05-08 18:13:57 +10:00
deoxxa
668c95f04e make call stacks aware of native functions
* add stackFramesToPop argument to error factories
* put native functions in their own stack frames
* add tests for native stack frames
* amend Context functionality to account for native frames
2016-05-07 20:55:09 +10:00
deoxxa
bd5fb254e3 add source map support
This patch implements source map support in the parser, the runtime, the
script record, and the stack trace printing.

The library used to parse and use the source maps is gopkg.in/sourcemap.v1.
Unlike earlier versions of this patch, the consumer of otto does not need
parse the source map on their own - it's now handled similarly to parsing
JavaScript content.

To use a source map, the consumer must explicitly parse their source into
a `Script` object with `Otto.CompileWithSourceMap`. The script record
returned from that call will carry source map information with it, and
all location-related functions should reflect the original source
positions.
2016-05-02 19:34:04 +10: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
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
709a0aa7ff Value.string(), .float64(), .bool(), etc. 2014-06-06 21:29:40 -07:00
Robert Krimen
918abeb8d8 The zero value of Value is now defined to be undefined
Previously, it was a publically accessible but invalid value (valueEmpty).

* Deprecate internal use of UndefinedValue(), NullValue(), FalseValue(), TrueValue()
* Guard against Empty, Result, Reference values from escaping the package
2014-05-28 21:23:32 -07:00
Robert Krimen
ad8a97c028 New parser
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
2014-04-10 20:42:25 -07:00
Robert Krimen
aef9bfcb9a Fix "memory leak" by gelcapping panic values with _exception
Basically, the Go runtime sees the gelcap shell of the exception,
which dissolves (payload is set to nil) once we catch the error.

This prevents the Go runtime from hanging onto a heavy object for the
panic log (or whatever it is doing with the panic value).

This fixes #59
2014-02-21 18:24:07 -08:00
Robert Krimen
4ebf6416d0 Fix Uint32 Array/String indexing
Also, a bunch of toValue_* streamlining
And maybe a few miscellaneous tweaks
2013-06-22 15:49:22 +02:00
Robert Krimen
73bf2f9fa8 Implement return/break/continue without panic/recover
This fixes #25
2013-06-13 22:17:04 -07:00
Robert Krimen
d5ced8c71f Slightly better error return on an uncaught panic 2013-04-20 22:30:27 -07:00
Robert Krimen
20d2e8bba6 gofmt
Ugh.
2013-01-25 09:59:42 -08:00
Robert Krimen
30a04e1992 URIError => SyntaxError 2012-11-15 16:06:13 -08:00
Robert Krimen
776f4f96c5 Catch *_syntaxError 2012-10-11 21:44:56 -07:00
Robert Krimen
c6e45a7118 Change getIdentifierReference to accept a node argument
To track/report where errors are coming from
2012-10-09 17:26:08 -07:00
Robert Krimen
ade6a169be Partially fix ReferenceError origin reporting 2012-10-09 17:19:29 -07:00
Robert Krimen
326264ae3e Line tracking for error reporting 2012-10-09 16:41:45 -07:00
Robert Krimen
4a8c7ffc00 Initial commit 2012-10-05 18:47:53 -07:00