aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/robertkrimen/otto/type_error.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/robertkrimen/otto/type_error.go')
-rw-r--r--vendor/github.com/robertkrimen/otto/type_error.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/robertkrimen/otto/type_error.go b/vendor/github.com/robertkrimen/otto/type_error.go
new file mode 100644
index 000000000..84e5d79b1
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_error.go
@@ -0,0 +1,24 @@
+package otto
+
+func (rt *_runtime) newErrorObject(name string, message Value, stackFramesToPop int) *_object {
+ self := rt.newClassObject("Error")
+ if message.IsDefined() {
+ msg := message.string()
+ self.defineProperty("message", toValue_string(msg), 0111, false)
+ self.value = newError(rt, name, stackFramesToPop, msg)
+ } else {
+ self.value = newError(rt, name, stackFramesToPop)
+ }
+
+ self.defineOwnProperty("stack", _property{
+ value: _propertyGetSet{
+ rt.newNativeFunction("get", "internal", 0, func(FunctionCall) Value {
+ return toValue_string(self.value.(_error).formatWithStack())
+ }),
+ &_nilGetSetObject,
+ },
+ mode: modeConfigureMask & modeOnMask,
+ }, false)
+
+ return self
+}