Repository navigation
Expand file tree
/
Copy patherror.go
More file actions
100 lines (79 loc) · 3.23 KB
/
Copy patherror.go
File metadata and controls
100 lines (79 loc) · 3.23 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package posthog
import (
"errors"
"fmt"
)
// ConfigError is returned by NewWithConfig when a Config field has an invalid value.
type ConfigError struct {
// A human-readable message explaining why the configuration field's value
// is invalid.
Reason string
// The name of the configuration field that was carrying an invalid value.
Field string
// The value of the configuration field that caused the error.
Value interface{}
}
// Error returns a human-readable configuration error message.
func (e ConfigError) Error() string {
return fmt.Sprintf("posthog.NewWithConfig: %s (posthog.Config.%s: %#v)", e.Reason, e.Field, e.Value)
}
// FieldError describes an invalid required field in a message passed to the SDK.
type FieldError struct {
// The human-readable representation of the type of structure that wasn't
// initialized properly.
Type string
// The name of the field that wasn't properly initialized.
Name string
// The value of the field that wasn't properly initialized.
Value interface{}
}
// Error returns a human-readable field validation error message.
func (e FieldError) Error() string {
return fmt.Sprintf("%s.%s: invalid field value: %#v", e.Type, e.Name, e.Value)
}
type requiredStringField struct {
name string
value string
}
func validateRequiredStringFields(typeName string, fields ...requiredStringField) error {
for _, field := range fields {
if field.value == "" {
return FieldError{
Type: typeName,
Name: field.name,
Value: field.value,
}
}
}
return nil
}
var (
// This error is returned by methods of the `Client` interface when they are
// called after the client was already closed.
ErrClosed = errors.New("the client was already closed")
// This error is used to notify the application that too many requests are
// already being sent and no more messages can be accepted.
ErrTooManyRequests = errors.New("too many requests are already in-flight")
// This error is used to notify the client callbacks that a message send
// failed because the JSON representation of a message exceeded the upper
// limit.
ErrMessageTooBig = errors.New("the message exceeds the maximum allowed size")
// ErrNoSecretKey is returned when a SecretKey is required for the requested
// operation but was not configured.
ErrNoSecretKey = errors.New("no SecretKey provided")
// ErrNoPersonalAPIKey is a deprecated alias for ErrNoSecretKey. It refers to
// the same error value, so errors.Is checks against either name still match.
//
// Deprecated: use ErrNoSecretKey.
ErrNoPersonalAPIKey = ErrNoSecretKey
// ErrNoDistinctID is returned when distinct_id is required for the requested
// operation but was not provided.
ErrNoDistinctID = errors.New("no distinct_id provided")
// ErrQueueFull is returned by Enqueue/EnqueueWithContext when the in-memory
// message queue is full. The message is dropped (not retried) and the drop is
// reported only through this returned error, not through Callback.Failure.
ErrQueueFull = errors.New("the message queue is full, the message was dropped")
// ErrSDKDisabled is returned by every method of a disabled client: one built
// with Config.Disabled, or with an empty or personal (phx_) project API key.
ErrSDKDisabled = errors.New("posthog SDK is disabled")
)