Source File
errors.go
Belonging Package
github.com/reeflective/console
package consoleimport ()type (// ErrorHandler is a function that handles errors.//// The handler can choose not to bubble up the error by returning nil.ErrorHandler func(err error) error// Err is the Console base error type.//// All errors that bubble up to the error handler should be// wrapped in this error type.//// There are more concrete error types that wrap this one defined below// this allow for easy use of errors.As.Err struct {err errormessage string}// PreReadError is an error that occurs during the pre-read phase.PreReadError struct{ Err }// ParseError is an error that occurs during the parsing phase.ParseError struct{ Err }// LineHookError is an error that occurs during the line hook phase.LineHookError struct{ Err }// ExecutionError is an error that occurs during the execution phase.ExecutionError struct{ Err })func defaultErrorHandler( error) error {fmt.Fprintf(os.Stderr, "Error: %s\n", )return nil}// newError creates a new Err.func newError( error, string) Err {return Err{err: ,message: ,}}// Error returns the error message with an optional// message prefix.func ( Err) () string {if len(.message) > 0 {return fmt.Sprintf("%s: %s", .message, .err.Error())}return .err.Error()}// Unwrap implements the errors Unwrap interface.func ( Err) () error {return .err}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |