forked from amazon-ion/ion-hash-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherr.go
65 lines (53 loc) · 1.92 KB
/
err.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
62
63
64
65
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ionhash
import (
"fmt"
"github.com/amzn/ion-go/ion"
)
// An InvalidOperationError is returned when a method call is invalid for the struct's current state.
type InvalidOperationError struct {
structName string
methodName string
message string
}
func (e *InvalidOperationError) Error() string {
if e.message != "" {
return fmt.Sprintf(`ionhash: Invalid operation at %v.%v: %v`, e.structName, e.methodName, e.message)
}
return fmt.Sprintf(`ionhash: Invalid operation error in %v.%v`, e.structName, e.methodName)
}
// InvalidArgumentError is returned when one of the arguments given to a function was not valid.
type InvalidArgumentError struct {
argumentName string
argumentValue interface{}
}
func (e *InvalidArgumentError) Error() string {
return fmt.Sprintf(`ionhash: Invalid value: "%v" specified for argument: %s`, e.argumentValue, e.argumentName)
}
// InvalidIonTypeError is returned when processing an unexpected Ion type.
type InvalidIonTypeError struct {
ionType ion.Type
}
func (e *InvalidIonTypeError) Error() string {
return fmt.Sprintf(`ionhash: Invalid Ion type: %s`, e.ionType.String())
}
// UnknownSymbolError is returned when processing an unknown field name symbol.
type UnknownSymbolError struct {
sid int64
}
func (e *UnknownSymbolError) Error() string {
return fmt.Sprintf(`ionhash: Unknown text for sid %d`, e.sid)
}