-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathErrors.alusus
46 lines (40 loc) · 1.63 KB
/
Errors.alusus
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
@merge module Stripe {
module Errors {
def UNAUTHENTICATED: "stripe_unauthenticated";
def UNAUTHENTICATED_MSG: "Authentication error";
func unauthenticated(): SrdRef[GenericError] {
return GenericError.new(UNAUTHENTICATED, UNAUTHENTICATED_MSG);
}
def CONNECTION: "stripe_connection";
def CONNECTION_MSG: "Connection error";
func connection(): SrdRef[GenericError] {
return GenericError.new(CONNECTION, CONNECTION_MSG);
}
def UNEXPECTED: "stripe_unexpected";
def UNEXPECTED_MSG: "Unexpected error";
func unexpected(): SrdRef[GenericError] {
return GenericError.new(UNEXPECTED, UNEXPECTED_MSG);
}
def NOT_FOUND: "stripe_not_found";
def NOT_FOUND_MSG: "Requested item is not found";
func notFound(): SrdRef[GenericError] {
return GenericError.new(NOT_FOUND, NOT_FOUND_MSG);
}
def INVALID_PARAM: "stripe_invalid_param";
def INVALID_PARAM_MSG: "Invalid request parameter";
func invalidParam(paramName: String): SrdRef[InvalidParamError] {
return InvalidParamError.new(paramName);
}
class InvalidParamError {
@injection def error: GenericError;
def paramName: String;
func new(pn: String): SrdRef[InvalidParamError] {
return SrdRef[InvalidParamError].construct().{
code = INVALID_PARAM;
message = String.format("%s. Param: %s", INVALID_PARAM_MSG, pn.buf);
paramName = pn;
}
}
}
}
}