1 // Copyright (c) 2013-2015 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
11 // MessageError describes an issue with a message.
12 // An example of some potential issues are messages from the wrong bitcoin
13 // network, invalid commands, mismatched checksums, and exceeding max payloads.
15 // This provides a mechanism for the caller to type assert the error to
16 // differentiate between general io errors such as io.EOF and issues that
17 // resulted from malformed messages.
18 type MessageError struct {
19 Func string // Function name
20 Description string // Human readable description of the issue
23 // Error satisfies the error interface and prints human-readable errors.
24 func (e *MessageError) Error() string {
26 return fmt.Sprintf("%v: %v", e.Func, e.Description)
31 // messageError creates an error for the given function and description.
32 func messageError(f string, desc string) *MessageError {
33 return &MessageError{Func: f, Description: desc}