-
Notifications
You must be signed in to change notification settings - Fork 31
/
errors.go
75 lines (59 loc) · 1.92 KB
/
errors.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
66
67
68
69
70
71
72
73
74
75
// Copyright 2019-2020 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
package errors
import (
"fmt"
"google.golang.org/grpc/codes"
)
// New creates a new internal error
func New(msg string) error {
return withError(codes.Internal, msg, nil)
}
// Newf creates a new internal error with a message format
func Newf(f string, args ...interface{}) error {
return withError(codes.Internal, fmt.Sprintf(f, args...), nil)
}
// Internal ...
func Internal(msg string, err error, tags ...Tag) error {
return withError(codes.Internal, msg, err)
}
// InvalidArgument ...
func InvalidArgument(msg string, tags ...Tag) error {
return withMessage(codes.InvalidArgument, msg, tags...)
}
// AlreadyExists ...
func AlreadyExists(msg string, tags ...Tag) error {
return withMessage(codes.AlreadyExists, msg, tags...)
}
// NotFound ...
func NotFound(msg string, tags ...Tag) error {
return withMessage(codes.NotFound, msg, tags...)
}
// PermissionDenied ...
func PermissionDenied(msg string, tags ...Tag) error {
return withMessage(codes.PermissionDenied, msg, tags...)
}
// Unimplemented ...
func Unimplemented(msg string, tags ...Tag) error {
return withMessage(codes.Unimplemented, msg, tags...)
}
// ResourceExhausted ...
func ResourceExhausted(msg string, tags ...Tag) error {
return withMessage(codes.ResourceExhausted, msg, tags...)
}
// Unauthenticated ...
func Unauthenticated(msg string, tags ...Tag) error {
return withMessage(codes.Unauthenticated, msg, tags...)
}
// Unavailable ...
func Unavailable(msg string, tags ...Tag) error {
return withMessage(codes.Unavailable, msg, tags...)
}
// DeadlineExceeded ...
func DeadlineExceeded(msg string, tags ...Tag) error {
return withMessage(codes.DeadlineExceeded, msg, tags...)
}
// Canceled ...
func Canceled(msg string, tags ...Tag) error {
return withMessage(codes.Canceled, msg, tags...)
}