| 1 | package model |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // MapKeyNotFound is returned when a key is not found in a map. |
| 6 | type MapKeyNotFound struct { |
| 7 | Key string |
| 8 | } |
| 9 | |
| 10 | // Error returns the error message. |
| 11 | func (e MapKeyNotFound) Error() string { |
| 12 | return fmt.Sprintf("map key not found: %q", e.Key) |
| 13 | } |
| 14 | |
| 15 | // SliceIndexOutOfRange is returned when an index is invalid. |
| 16 | type SliceIndexOutOfRange struct { |
| 17 | Index int |
| 18 | } |
| 19 | |
| 20 | // Error returns the error message. |
| 21 | func (e SliceIndexOutOfRange) Error() string { |
| 22 | return fmt.Sprintf("slice index out of range: %d", e.Index) |
| 23 | } |
| 24 | |
| 25 | // ErrIncompatibleTypes is returned when two values are incompatible. |
| 26 | type ErrIncompatibleTypes struct { |
| 27 | A *Value |
| 28 | B *Value |
| 29 | } |
| 30 | |
| 31 | // Error returns the error message. |
| 32 | func (e ErrIncompatibleTypes) Error() string { |
| 33 | return fmt.Sprintf("incompatible types: %s and %s", e.A.Type(), e.B.Type()) |
| 34 | } |
| 35 | |
| 36 | type ErrUnexpectedType struct { |
| 37 | Expected Type |
| 38 | Actual Type |
| 39 | } |
| 40 | |
| 41 | func (e ErrUnexpectedType) Error() string { |
| 42 | return fmt.Sprintf("unexpected type: expected %s, got %s", e.Expected, e.Actual) |
| 43 | } |
| 44 | |
| 45 | type ErrUnexpectedTypes struct { |
| 46 | Expected []Type |
| 47 | Actual Type |
| 48 | } |
| 49 | |
| 50 | func (e ErrUnexpectedTypes) Error() string { |
| 51 | return fmt.Sprintf("unexpected type: expected %v, got %s", e.Expected, e.Actual) |
| 52 | } |