File: type_error.go

package info (click to toggle)
golang-github-robertkrimen-otto 0.0~git20200922.ef014fd-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,796 kB
  • sloc: perl: 1,227; makefile: 79
file content (24 lines) | stat: -rw-r--r-- 697 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}