David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame^] | 1 | // Copyright 2015 Canonical Ltd. |
| 2 | // Licensed under the LGPLv3, see LICENCE file for details. |
| 3 | |
| 4 | package schema |
| 5 | |
| 6 | import ( |
| 7 | "fmt" |
| 8 | ) |
| 9 | |
| 10 | type error_ struct { |
| 11 | want string |
| 12 | got interface{} |
| 13 | path []string |
| 14 | } |
| 15 | |
| 16 | func (e error_) Error() string { |
| 17 | path := pathAsPrefix(e.path) |
| 18 | if e.want == "" { |
| 19 | return fmt.Sprintf("%sunexpected value %#v", path, e.got) |
| 20 | } |
| 21 | if e.got == nil { |
| 22 | return fmt.Sprintf("%sexpected %s, got nothing", path, e.want) |
| 23 | } |
| 24 | return fmt.Sprintf("%sexpected %s, got %T(%#v)", path, e.want, e.got, e.got) |
| 25 | } |