27 lines
556 B
Go
27 lines
556 B
Go
package errors
|
|
|
|
import "fmt"
|
|
|
|
// ReturnCountMismatch error is created when the number of returned values doesn't match the return type.
|
|
type ReturnCountMismatch struct {
|
|
Count int
|
|
ExpectedCount int
|
|
}
|
|
|
|
// Error generates the string representation.
|
|
func (err *ReturnCountMismatch) Error() string {
|
|
values := "values"
|
|
|
|
if err.Count == 1 {
|
|
values = "value"
|
|
}
|
|
|
|
types := "types"
|
|
|
|
if err.ExpectedCount == 1 {
|
|
types = "type"
|
|
}
|
|
|
|
return fmt.Sprintf("Returns %d %s in a function with %d return %s", err.Count, values, err.ExpectedCount, types)
|
|
}
|