-
Notifications
You must be signed in to change notification settings - Fork 48
/
errors.go
61 lines (51 loc) · 1.43 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package annotate
import (
"fmt"
"time"
"github.com/paulmach/osm"
"github.com/paulmach/osm/annotate/internal/core"
)
// NoHistoryError is returned if there is no entry in the history
// map for a specific child.
type NoHistoryError struct {
ID osm.FeatureID
}
// Error returns a pretty string of the error.
func (e *NoHistoryError) Error() string {
return fmt.Sprintf("element history not found for %v", e.ID)
}
// NoVisibleChildError is returned if there are no visible children
// for a parent at a given time.
type NoVisibleChildError struct {
ID osm.FeatureID
Timestamp time.Time
}
// Error returns a pretty string of the error.
func (e *NoVisibleChildError) Error() string {
return fmt.Sprintf("no visible child for %v at %v", e.ID, e.Timestamp)
}
// UnsupportedMemberTypeError is returned if a relation member is not a
// node, way or relation.
type UnsupportedMemberTypeError struct {
RelationID osm.RelationID
MemberType osm.Type
Index int
}
// Error returns a pretty string of the error.
func (e *UnsupportedMemberTypeError) Error() string {
return fmt.Sprintf("unsupported member type %v for relation %d at %d", e.MemberType, e.RelationID, e.Index)
}
func mapErrors(err error) error {
switch t := err.(type) {
case *core.NoHistoryError:
return &NoHistoryError{
ID: t.ChildID,
}
case *core.NoVisibleChildError:
return &NoVisibleChildError{
ID: t.ChildID,
Timestamp: t.Timestamp,
}
}
return err
}