-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
49 lines (40 loc) · 1.19 KB
/
errors.go
File metadata and controls
49 lines (40 loc) · 1.19 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
package mina
import (
"fmt"
"strings"
)
// GraphQLError is returned when the GraphQL endpoint returns an error response.
type GraphQLError struct {
Errors []GraphQLErrorEntry
QueryName string
}
// GraphQLErrorEntry represents a single error from a GraphQL response.
type GraphQLErrorEntry struct {
Message string `json:"message"`
}
func (e *GraphQLError) Error() string {
messages := make([]string, len(e.Errors))
for i, entry := range e.Errors {
messages[i] = entry.Message
}
return fmt.Sprintf("GraphQL error in %s: %s", e.QueryName, strings.Join(messages, "; "))
}
// ConnectionError is returned when the client cannot connect to the daemon after retries.
type ConnectionError struct {
QueryName string
Retries int
LastError error
}
func (e *ConnectionError) Error() string {
return fmt.Sprintf("failed to execute %s after %d attempts: %v", e.QueryName, e.Retries, e.LastError)
}
func (e *ConnectionError) Unwrap() error {
return e.LastError
}
// AccountNotFoundError is returned when the requested account does not exist.
type AccountNotFoundError struct {
PublicKey string
}
func (e *AccountNotFoundError) Error() string {
return fmt.Sprintf("account not found: %s", e.PublicKey)
}