| 1 |
package gorp |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
) |
| 6 |
|
| 7 |
// A non-fatal error, when a select query returns columns that do not exist |
| 8 |
// as fields in the struct it is being mapped to |
| 9 |
type NoFieldInTypeError struct { |
| 10 |
TypeName string |
| 11 |
MissingColNames []string |
| 12 |
} |
| 13 |
|
| 14 |
func (err *NoFieldInTypeError) Error() string { |
| 15 |
return fmt.Sprintf("gorp: No fields %+v in type %s", err.MissingColNames, err.TypeName) |
| 16 |
} |
| 17 |
|
| 18 |
// returns true if the error is non-fatal (ie, we shouldn't immediately return) |
| 19 |
func NonFatalError(err error) bool { |
| 20 |
switch err.(type) { |
| 21 |
case *NoFieldInTypeError: |
| 22 |
return true |
| 23 |
default: |
| 24 |
return false |
| 25 |
} |
| 26 |
} |