blob: f62f58e36e12aac605f46c2d17f01ced58148c2c [file] [log] [blame]
David K. Bainbridge528b3182017-01-23 08:51:59 -08001// Copyright 2015 Canonical Ltd.
2// Licensed under the LGPLv3, see LICENCE file for details.
3
4package schema
5
6import (
7 "fmt"
8)
9
10type error_ struct {
11 want string
12 got interface{}
13 path []string
14}
15
16func (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}