-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patherrors.go
More file actions
28 lines (24 loc) · 783 Bytes
/
Copy patherrors.go
File metadata and controls
28 lines (24 loc) · 783 Bytes
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
// Copyright (c) 2017 Steven Roose <steven@stevenroose.org>.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package gonfig
import (
"errors"
"fmt"
"reflect"
)
// parseError returns a nicely formatted error indicating that we failed to
// parse v into type t.
func parseError(v string, t reflect.Type, err error) error {
msg := fmt.Sprintf("failed to parse '%v' into type %v", v, t)
if err != nil {
msg += ": " + err.Error()
}
return errors.New(msg)
}
// convertibleError returns a nicely formatted error indicating that the value
// v is not convertible to type t.
func convertibleError(v reflect.Value, t reflect.Type) error {
return fmt.Errorf(
"incompatible type: %v not convertible to %v", v.Type(), t)
}