Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error interface { Error() string Stacktrace() Error Trace(offset int, format string, args ...interface{}) Error Data() interface{} }
Usage with arbitrary error data:
```go
// Error construction type MyError struct{} var err1 error = NewErrorWithData(MyError{}, "my message") ... // Wrapping var err2 error = ErrorWrap(err1, "another message") if (err1 != err2) { panic("should be the same") ... // Error handling switch err2.Data().(type){ case MyError: ... default: ... }
```
func NewErrorWithData ¶
func NewErrorWithData(data interface{}) Error
New Error with specified data.
type FmtError ¶
type FmtError struct {
// contains filtered or unexported fields
}
FmtError is the data type for NewError() (e.g. NewError().Data().(FmtError)) Theoretically it could be used to switch on the format string.
```go
// Error construction var err1 error = NewError("invalid username %v", "BOB") var err2 error = NewError("another kind of error") ... // Error handling switch err1.Data().(cmn.FmtError).Format() { case "invalid username %v": ... case "another kind of error": ... default: ... }
```
Click to show internal directories.
Click to hide internal directories.