-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDieCode.pm
154 lines (151 loc) · 3.17 KB
/
DieCode.pm
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Copyright (c) 1999-2005 bivio Software, Inc. All rights reserved.
# $Id$
package Bivio::DieCode;
use strict;
use base 'Bivio::Type::Enum';
__PACKAGE__->compile([
UNKNOWN => [
0,
undef,
'unexpected error',
],
NOT_FOUND => [
1,
undef,
'entity was not found',
],
ALREADY_EXISTS => [
2,
undef,
'attempt to create an entity which already exists',
],
FORBIDDEN => [
3,
undef,
'operation is not allowed on entity',
],
CATCH_WITHIN_DIE => [
4,
undef,
'internal program error (4)',
],
INVALID_DIE_CODE => [
5,
undef,
'internal program error (5)',
],
DIE => [
6,
'internal program error (6)',
],
DIE_WITHIN_HANDLE_DIE => [
7,
undef,
'internal program error (7)',
],
MISSING_COOKIES => [
8,
undef,
'browser did not return all necessary cookies',
],
VERSION_MISMATCH => [
9,
undef,
'user request using invalid or old form, query, or uri',
],
CORRUPT_QUERY => [
10,
undef,
'user request contains invalid query value',
],
SERVER_REDIRECT_TASK => [
11,
undef,
'direct dispatcher to switch to new task',
],
CORRUPT_FORM => [
12,
undef,
'user request contains invalid form',
],
CLIENT_REDIRECT_TASK => [
13,
undef,
'direct user agent to new task',
],
TOO_MANY => [
14,
undef,
'the request returned too much data or too many records',
],
NO_RESOURCES => [
15,
undef,
'insufficient resources to satisfy the request',
],
IO_ERROR => [
16,
undef,
'file system error',
],
CLIENT_ERROR => [
17,
undef,
'error reading or writing to the client',
],
UPDATE_COLLISION => [
18,
undef,
'two or more people are trying to update your records simultaneously',
],
DB_ERROR => [
19,
undef,
'unexpected error while communicating with database',
],
MAIL_LOOP => [
20,
undef,
'avoid a mail loop',
],
UNEXPECTED_EOF => [
21,
undef,
'unexpected end of file',
],
CONFIG_ERROR => [
22,
undef,
'missing or incorrect configuration. Please check your bconf file.',
],
DB_CONSTRAINT => [
23,
undef,
'unexpected database constraint violation',
],
MODEL_NOT_FOUND => [
24,
undef,
'model was not found',
],
INVALID_OP => [
25,
undef,
'invalid operation',
],
INPUT_TOO_LARGE => [
26,
undef,
'input too large',
],
]);
sub throw_die {
# (self, hash_ref) : undef
# (self, scalar) : undef
# Dies in caller with this die code.
my($self, $attrs) = @_;
Bivio::Die->throw($self,
ref($attrs) eq 'HASH' ? $attrs : {message => $attrs},
caller);
}
1;