MCPcopy Create free account
hub / github.com/apache/fory / Error

Method Error

go/fory/errors.go:125–151  ·  view source on GitHub ↗

Error implements the error interface with lazy formatting

()

Source from the content-addressed store, hash-verified

123
124// Error implements the error interface with lazy formatting
125func (e Error) Error() string {
126 stack := e.reverseStackString()
127 switch e.kind {
128 case ErrKindOK:
129 return ""
130 case ErrKindBufferOutOfBound:
131 if e.message != "" {
132 return e.message + stack
133 }
134 return fmt.Sprintf("buffer out of bound: offset=%d, need=%d, size=%d", e.offset, e.need, e.size) + stack
135 case ErrKindTypeMismatch:
136 if e.message != "" {
137 return e.message + stack
138 }
139 return fmt.Sprintf("type mismatch: actual=%d, expected=%d", e.actualType, e.expectedType) + stack
140 case ErrKindHashMismatch:
141 if e.message != "" {
142 return e.message + stack
143 }
144 return fmt.Sprintf("hash mismatch: actual=%d, expected=%d", e.actualHash, e.expectedHash) + stack
145 default:
146 if e.message != "" {
147 return e.message + stack
148 }
149 return fmt.Sprintf("fory error: kind=%d", e.kind) + stack
150 }
151}
152
153// BufferOutOfBoundError creates a buffer out of bound error
154//

Calls 1

reverseStackStringMethod · 0.95