Source File
error.go
Belonging Package
runtime
package runtime
import
RuntimeError()
}
type TypeAssertionError struct {
_interface *_type
concrete *_type
asserted *_type
missingMethod string // one method needed by Interface, missing from Concrete
}
func (*TypeAssertionError) () {}
func ( *TypeAssertionError) () string {
:= "interface"
if ._interface != nil {
= ._interface.string()
}
:= .asserted.string()
if .concrete == nil {
return "interface conversion: " + + " is nil, not " +
}
:= .concrete.string()
if .missingMethod == "" {
:= "interface conversion: " + + " is " + + ", not " +
if .concrete.pkgpath() != .asserted.pkgpath() {
+= " (types from different packages)"
} else {
+= " (types from different scopes)"
}
}
return
}
return "interface conversion: " + + " is not " + +
": missing method " + .missingMethod
}
type errorString string
func ( errorString) () {}
func ( errorString) () string {
return "runtime error: " + string()
}
type errorAddressString struct {
msg string // error message
addr uintptr // memory address where the error occurred
}
func ( errorAddressString) () {}
func ( errorAddressString) () string {
return "runtime error: " + .msg
}
func ( errorAddressString) () uintptr {
return .addr
}
type plainError string
func ( plainError) () {}
func ( plainError) () string {
return string()
}
type boundsError struct {
x int64
signed bool
code boundsErrorCode
}
type boundsErrorCode uint8
const (
boundsIndex boundsErrorCode = iota // s[x], 0 <= x < len(s) failed
boundsSliceAlen // s[?:x], 0 <= x <= len(s) failed
boundsSliceAcap // s[?:x], 0 <= x <= cap(s) failed
boundsSliceB // s[x:y], 0 <= x <= y failed (but boundsSliceA didn't happen)
boundsSlice3Alen // s[?:?:x], 0 <= x <= len(s) failed
boundsSlice3Acap // s[?:?:x], 0 <= x <= cap(s) failed
boundsSlice3B // s[?:x:y], 0 <= x <= y failed (but boundsSlice3A didn't happen)
boundsSlice3C // s[x:y:?], 0 <= x <= y failed (but boundsSlice3A/B didn't happen)
)
var boundsErrorFmts = [...]string{
boundsIndex: "index out of range [%x] with length %y",
boundsSliceAlen: "slice bounds out of range [:%x] with length %y",
boundsSliceAcap: "slice bounds out of range [:%x] with capacity %y",
boundsSliceB: "slice bounds out of range [%x:%y]",
boundsSlice3Alen: "slice bounds out of range [::%x] with length %y",
boundsSlice3Acap: "slice bounds out of range [::%x] with capacity %y",
boundsSlice3B: "slice bounds out of range [:%x:%y]",
boundsSlice3C: "slice bounds out of range [%x:%y:]",
}
var boundsNegErrorFmts = [...]string{
boundsIndex: "index out of range [%x]",
boundsSliceAlen: "slice bounds out of range [:%x]",
boundsSliceAcap: "slice bounds out of range [:%x]",
boundsSliceB: "slice bounds out of range [%x:]",
boundsSlice3Alen: "slice bounds out of range [::%x]",
boundsSlice3Acap: "slice bounds out of range [::%x]",
boundsSlice3B: "slice bounds out of range [:%x:]",
boundsSlice3C: "slice bounds out of range [%x::]",
}
func ( boundsError) () {}
func ( []byte, int64, bool) []byte {
if && < 0 {
= append(, '-')
= -
}
var [20]byte
= append(, itoa([:], uint64())...)
return
}
func ( boundsError) () string {
:= boundsErrorFmts[.code]
if .signed && .x < 0 {
= boundsNegErrorFmts[.code]
func ( interface{}) {
switch v := .(type) {
case nil:
print("nil")
case bool:
print()
case int:
print()
case int8:
print()
case int16:
print()
case int32:
print()
case int64:
print()
case uint:
print()
case uint8:
print()
case uint16:
print()
case uint32:
print()
case uint64:
print()
case uintptr:
print()
case float32:
print()
case float64:
print()
case complex64:
print()
case complex128:
print()
case string:
print()
default:
printanycustomtype()
}
}
func ( interface{}) {
:= efaceOf(&)
:= ._type.string()
switch ._type.kind {
case kindString:
print(, `("`, *(*string)(.data), `")`)
case kindBool:
print(, "(", *(*bool)(.data), ")")
case kindInt:
print(, "(", *(*int)(.data), ")")
case kindInt8:
print(, "(", *(*int8)(.data), ")")
case kindInt16:
print(, "(", *(*int16)(.data), ")")
case kindInt32:
print(, "(", *(*int32)(.data), ")")
case kindInt64:
print(, "(", *(*int64)(.data), ")")
case kindUint:
print(, "(", *(*uint)(.data), ")")
case kindUint8:
print(, "(", *(*uint8)(.data), ")")
case kindUint16:
print(, "(", *(*uint16)(.data), ")")
case kindUint32:
print(, "(", *(*uint32)(.data), ")")
case kindUint64:
print(, "(", *(*uint64)(.data), ")")
case kindUintptr:
print(, "(", *(*uintptr)(.data), ")")
case kindFloat32:
print(, "(", *(*float32)(.data), ")")
case kindFloat64:
print(, "(", *(*float64)(.data), ")")
case kindComplex64:
print(, *(*complex64)(.data))
case kindComplex128:
print(, *(*complex128)(.data))
default:
print("(", , ") ", .data)
}
}
func () {
:= getcallerpc()
:= bytealg.IndexByteString(, '(')
if < 0 {
throw("panicwrap: no ( in " + )
}
:= [:-1]
if +2 >= len() || [-1:+2] != ".(*" {
throw("panicwrap: unexpected string after package name: " + )
}
= [+2:]
= bytealg.IndexByteString(, ')')
if < 0 {
throw("panicwrap: no ) in " + )
}
if +2 >= len() || [:+2] != ")." {
throw("panicwrap: unexpected string after type name: " + )
}
:= [:]
:= [+2:]
panic(plainError("value method " + + "." + + "." + + " called using nil *" + + " pointer"))
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |