1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00

implement configurable stack trace limit

This commit is contained in:
deoxxa
2016-05-08 17:54:26 +10:00
parent 96f57ba9bb
commit ccf93984d9
3 changed files with 17 additions and 5 deletions

10
otto.go
View File

@@ -245,6 +245,7 @@ func New() *Otto {
runtime: newContext(),
}
self.runtime.otto = self
self.runtime.traceLimit = 10
self.Set("console", self.runtime.newConsole())
registry.Apply(func(entry registry.Entry) {
@@ -380,6 +381,15 @@ func (self Otto) SetStackDepthLimit(limit int) {
self.runtime.stackLimit = limit
}
// SetStackTraceLimit sets an upper limit to the number of stack frames that
// otto will use when formatting an error's stack trace. By default, the limit
// is 10. This is consistent with V8 and SpiderMonkey.
//
// TODO: expose via `Error.stackTraceLimit`
func (self Otto) SetStackTraceLimit(limit int) {
self.runtime.traceLimit = limit
}
// MakeCustomError creates a new Error object with the given name and message,
// returning it as a Value.
func (self Otto) MakeCustomError(name, message string) Value {