File: error.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (59 lines) | stat: -rw-r--r-- 1,799 bytes parent folder | download | duplicates (7)
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
package expression

import (
	"fmt"
)

// InvalidParameterError is returned if invalid parameters are encountered. This
// error specifically refers to situations where parameters are non-empty but
// have an invalid syntax/format. The error message includes the function
// that returned the error originally and the parameter type that was deemed
// invalid.
//
// Example:
//
//	// err is of type InvalidParameterError
//	_, err := expression.Name("foo..bar").BuildOperand()
type InvalidParameterError struct {
	parameterType string
	functionName  string
}

func (ipe InvalidParameterError) Error() string {
	return fmt.Sprintf("%s error: invalid parameter: %s", ipe.functionName, ipe.parameterType)
}

func newInvalidParameterError(funcName, paramType string) InvalidParameterError {
	return InvalidParameterError{
		parameterType: paramType,
		functionName:  funcName,
	}
}

// UnsetParameterError is returned if parameters are empty and uninitialized.
// This error is returned if opaque structs (ConditionBuilder, NameBuilder,
// Builder, etc) are initialized outside of functions in the package, since all
// structs in the package are designed to be initialized with functions.
//
// Example:
//
//	// err is of type UnsetParameterError
//	_, err := expression.Builder{}.Build()
//	_, err := expression.NewBuilder().
//	            WithCondition(expression.ConditionBuilder{}).
//	            Build()
type UnsetParameterError struct {
	parameterType string
	functionName  string
}

func (upe UnsetParameterError) Error() string {
	return fmt.Sprintf("%s error: unset parameter: %s", upe.functionName, upe.parameterType)
}

func newUnsetParameterError(funcName, paramType string) UnsetParameterError {
	return UnsetParameterError{
		parameterType: paramType,
		functionName:  funcName,
	}
}