MCPcopy Index your code
hub / github.com/Shopify/go-lua / ArgumentError

Function ArgumentError

auxiliary.go:118–140  ·  view source on GitHub ↗

ArgumentError raises an error with a standard message that includes extraMessage as a comment. This function never returns. It is an idiom to use it in Go functions as lua.ArgumentError(l, args, "message") panic("unreachable")

(l *State, argCount int, extraMessage string)

Source from the content-addressed store, hash-verified

116// lua.ArgumentError(l, args, "message")
117// panic("unreachable")
118func ArgumentError(l *State, argCount int, extraMessage string) {
119 f, ok := Stack(l, 0)
120 if !ok { // no stack frame?
121 Errorf(l, "bad argument #%d (%s)", argCount, extraMessage)
122 return
123 }
124 d, _ := Info(l, "n", f)
125 if d.NameKind == "method" {
126 argCount-- // do not count 'self'
127 if argCount == 0 { // error is in the self argument itself?
128 Errorf(l, "calling '%s' on bad self (%s)", d.Name, extraMessage)
129 return
130 }
131 }
132 if d.Name == "" {
133 if pushGlobalFunctionName(l, f) {
134 d.Name, _ = l.ToString(-1)
135 } else {
136 d.Name = "?"
137 }
138 }
139 Errorf(l, "bad argument #%d to '%s' (%s)", argCount, d.Name, extraMessage)
140}
141
142func findField(l *State, objectIndex, level int) bool {
143 if level == 0 || !l.IsTable(-1) {

Callers 6

debug.goFile · 0.85
formatHelperFunction · 0.85
typeErrorFunction · 0.85
CheckAnyFunction · 0.85
ArgumentCheckFunction · 0.85
CheckOptionFunction · 0.85

Calls 5

StackFunction · 0.85
ErrorfFunction · 0.85
InfoFunction · 0.85
pushGlobalFunctionNameFunction · 0.85
ToStringMethod · 0.80

Tested by

no test coverage detected