-
Notifications
You must be signed in to change notification settings - Fork 8
/
errors.legacy.go.tmpl
90 lines (79 loc) · 5.08 KB
/
errors.legacy.go.tmpl
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
{{define "legacyErrors"}}
//
// Legacy errors
//
// Deprecated: Use fmt.Errorf() or WebRPCError.
func Errorf(err legacyError, format string, args ...interface{}) WebRPCError {
return err.WebRPCError.WithCausef(format, args...)
}
// Deprecated: Use .WithCause() method on WebRPCError.
func WrapError(err legacyError, cause error, format string, args ...interface{}) WebRPCError {
return err.WebRPCError.WithCausef("%v: %w", fmt.Errorf(format, args...), cause)
}
// Deprecated: Use fmt.Errorf() or WebRPCError.
func Failf(format string, args ...interface{}) WebRPCError {
return Errorf(ErrFail, format, args...)
}
// Deprecated: Use .WithCause() method on WebRPCError.
func WrapFailf(cause error, format string, args ...interface{}) WebRPCError {
return WrapError(ErrFail, cause, format, args...)
}
// Deprecated: Use fmt.Errorf() or WebRPCError.
func ErrorNotFound(format string, args ...interface{}) WebRPCError {
return Errorf(ErrNotFound, format, args...)
}
// Deprecated: Use fmt.Errorf() or WebRPCError.
func ErrorInvalidArgument(argument string, validationMsg string) WebRPCError {
return Errorf(ErrInvalidArgument, argument+" "+validationMsg)
}
// Deprecated: Use fmt.Errorf() or WebRPCError.
func ErrorRequiredArgument(argument string) WebRPCError {
return ErrorInvalidArgument(argument, "is required")
}
// Deprecated: Use fmt.Errorf() or WebRPCError.
func ErrorInternal(format string, args ...interface{}) WebRPCError {
return Errorf(ErrInternal, format, args...)
}
type legacyError struct { WebRPCError }
// Legacy errors (webrpc v0.10.0 and earlier). Will be removed.
var (
// Deprecated. Define errors in RIDL schema.
ErrCanceled = legacyError{WebRPCError{Code: -10000, Name: "ErrCanceled", Message: "canceled", HTTPStatus: 408 /* RequestTimeout */ }}
// Deprecated. Define errors in RIDL schema.
ErrUnknown = legacyError{WebRPCError{Code: -10001, Name: "ErrUnknown", Message: "unknown", HTTPStatus: 400 /* Bad Request */ }}
// Deprecated. Define errors in RIDL schema.
ErrFail = legacyError{WebRPCError{Code: -10002, Name: "ErrFail", Message: "fail", HTTPStatus: 422 /* Unprocessable Entity */ }}
// Deprecated. Define errors in RIDL schema.
ErrInvalidArgument = legacyError{WebRPCError{Code: -10003, Name: "ErrInvalidArgument", Message: "invalid argument", HTTPStatus: 400 /* BadRequest */ }}
// Deprecated. Define errors in RIDL schema.
ErrDeadlineExceeded = legacyError{WebRPCError{Code: -10004, Name: "ErrDeadlineExceeded", Message: "deadline exceeded", HTTPStatus: 408 /* RequestTimeout */ }}
// Deprecated. Define errors in RIDL schema.
ErrNotFound = legacyError{WebRPCError{Code: -10005, Name: "ErrNotFound", Message: "not found", HTTPStatus: 404 /* Not Found */ }}
// Deprecated. Define errors in RIDL schema.
ErrBadRoute = legacyError{WebRPCError{Code: -10006, Name: "ErrBadRoute", Message: "bad route", HTTPStatus: 404 /* Not Found */ }}
// Deprecated. Define errors in RIDL schema.
ErrAlreadyExists = legacyError{WebRPCError{Code: -10007, Name: "ErrAlreadyExists", Message: "already exists", HTTPStatus: 409 /* Conflict */ }}
// Deprecated. Define errors in RIDL schema.
ErrPermissionDenied = legacyError{WebRPCError{Code: -10008, Name: "ErrPermissionDenied", Message: "permission denied", HTTPStatus: 403 /* Forbidden */ }}
// Deprecated. Define errors in RIDL schema.
ErrUnauthenticated = legacyError{WebRPCError{Code: -10009, Name: "ErrUnauthenticated", Message: "unauthenticated", HTTPStatus: 401 /* Unauthorized */ }}
// Deprecated. Define errors in RIDL schema.
ErrResourceExhausted = legacyError{WebRPCError{Code: -10010, Name: "ErrResourceExhausted", Message: "resource exhausted", HTTPStatus: 403 /* Forbidden */ }}
// Deprecated. Define errors in RIDL schema.
ErrFailedPrecondition = legacyError{WebRPCError{Code: -10011, Name: "ErrFailedPrecondition", Message: "failed precondition", HTTPStatus: 412 /* Precondition Failed */ }}
// Deprecated. Define errors in RIDL schema.
ErrAborted = legacyError{WebRPCError{Code: -10012, Name: "ErrAborted", Message: "aborted", HTTPStatus: 409 /* Conflict */ }}
// Deprecated. Define errors in RIDL schema.
ErrOutOfRange = legacyError{WebRPCError{Code: -10013, Name: "ErrOutOfRange", Message: "out of range", HTTPStatus: 400 /* Bad Request */ }}
// Deprecated. Define errors in RIDL schema.
ErrUnimplemented = legacyError{WebRPCError{Code: -10014, Name: "ErrUnimplemented", Message: "unimplemented", HTTPStatus: 501 /* Not Implemented */ }}
// Deprecated. Define errors in RIDL schema.
ErrInternal = legacyError{WebRPCError{Code: -10015, Name: "ErrInternal", Message: "internal", HTTPStatus: 500 /* Internal Server Error */ }}
// Deprecated. Define errors in RIDL schema.
ErrUnavailable = legacyError{WebRPCError{Code: -10016, Name: "ErrUnavailable", Message: "unavailable", HTTPStatus: 503 /* Service Unavailable */ }}
// Deprecated. Define errors in RIDL schema.
ErrDataLoss = legacyError{WebRPCError{Code: -10017, Name: "ErrDataLoss", Message: "data loss", HTTPStatus: 500 /* Internal Server Error */ }}
// Deprecated. Define errors in RIDL schema.
ErrNone = legacyError{WebRPCError{Code: -10018, Name: "ErrNone", Message: "", HTTPStatus: 200 /* OK */ }}
)
{{- end }}