1 |
|
-module(mongoose_xmpp_errors). |
2 |
|
|
3 |
|
-compile([export_all, nowarn_export_all]). |
4 |
|
-include("mongoose_ns.hrl"). |
5 |
|
|
6 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7 |
|
%% Stanza Errors |
8 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9 |
|
|
10 |
|
-type stanza_error() :: |
11 |
|
bad_request | conflict | feature_not_implemented | forbidden | gone |
12 |
|
| internal_server_error | item_not_found | jid_malformed | not_acceptable |
13 |
|
| not_acceptable_cancel | not_acceptable_blocked | not_allowed | not_authorized |
14 |
|
| payment_required | recipient_unavailable | redirect | registration_required |
15 |
|
| remote_server_not_found | remote_server_timeout | resource_constraint |
16 |
|
| service_unavailable | service_unavailable_wait | subscription_required |
17 |
|
| unexpected_request | unexpected_request_cancel. |
18 |
|
|
19 |
|
-export_type([stanza_error/0]). |
20 |
|
|
21 |
|
bad_request() -> |
22 |
863 |
jlib:stanza_error(<<"400">>,<<"modify">>,<<"bad-request">>). |
23 |
|
|
24 |
|
conflict() -> |
25 |
208 |
jlib:stanza_error(<<"409">>,<<"cancel">>,<<"conflict">>). |
26 |
|
|
27 |
|
feature_not_implemented() -> |
28 |
406 |
jlib:stanza_error(<<"501">>,<<"cancel">>,<<"feature-not-implemented">>). |
29 |
|
|
30 |
|
forbidden() -> |
31 |
35 |
jlib:stanza_error(<<"403">>,<<"auth">>, <<"forbidden">>). |
32 |
|
|
33 |
|
gone() -> |
34 |
:-( |
jlib:stanza_error(<<"302">>,<<"modify">>,<<"gone">>). |
35 |
|
|
36 |
|
internal_server_error() -> |
37 |
7 |
jlib:stanza_error(<<"500">>,<<"wait">>, <<"internal-server-error">>). |
38 |
|
|
39 |
|
item_not_found() -> |
40 |
446 |
jlib:stanza_error(<<"404">>,<<"cancel">>,<<"item-not-found">>). |
41 |
|
|
42 |
|
jid_malformed() -> |
43 |
1 |
jlib:stanza_error(<<"400">>,<<"modify">>,<<"jid-malformed">>). |
44 |
|
|
45 |
|
not_acceptable() -> |
46 |
216 |
jlib:stanza_error(<<"406">>,<<"modify">>,<<"not-acceptable">>). |
47 |
|
|
48 |
|
not_acceptable_cancel() -> |
49 |
3 |
jlib:stanza_error(<<"406">>,<<"cancel">>,<<"not-acceptable">>). |
50 |
|
|
51 |
|
not_acceptable_blocked() -> |
52 |
4 |
jlib:stanza_error(<<"406">>,<<"cancel">>,<<"not-acceptable">>, <<"blocked">>, ?NS_BLOCKING_ERRORS). |
53 |
|
|
54 |
|
not_allowed() -> |
55 |
30 |
jlib:stanza_error(<<"405">>,<<"cancel">>,<<"not-allowed">>). |
56 |
|
|
57 |
|
not_authorized() -> |
58 |
:-( |
jlib:stanza_error(<<"401">>,<<"auth">>, <<"not-authorized">>). |
59 |
|
|
60 |
|
payment_required() -> |
61 |
:-( |
jlib:stanza_error(<<"402">>,<<"auth">>, <<"payment-required">>). |
62 |
|
|
63 |
|
recipient_unavailable() -> |
64 |
:-( |
jlib:stanza_error(<<"404">>,<<"wait">>, <<"recipient-unavailable">>). |
65 |
|
|
66 |
|
redirect() -> |
67 |
:-( |
jlib:stanza_error(<<"302">>,<<"modify">>,<<"redirect">>). |
68 |
|
|
69 |
|
registration_required() -> |
70 |
1 |
jlib:stanza_error(<<"407">>,<<"auth">>, <<"registration-required">>). |
71 |
|
|
72 |
|
remote_server_not_found() -> |
73 |
:-( |
jlib:stanza_error(<<"404">>,<<"cancel">>,<<"remote-server-not-found">>). |
74 |
|
|
75 |
|
remote_server_timeout() -> |
76 |
:-( |
jlib:stanza_error(<<"504">>,<<"wait">>, <<"remote-server-timeout">>). |
77 |
|
|
78 |
|
resource_constraint() -> |
79 |
:-( |
jlib:stanza_error(<<"500">>,<<"wait">>, <<"resource-constraint">>). |
80 |
|
|
81 |
|
service_unavailable() -> |
82 |
70 |
jlib:stanza_error(<<"503">>,<<"cancel">>,<<"service-unavailable">>). |
83 |
|
|
84 |
|
service_unavailable_wait() -> |
85 |
1 |
jlib:stanza_error(<<"502">>,<<"wait">>,<<"service-unavailable">>). |
86 |
|
|
87 |
|
subscription_required() -> |
88 |
:-( |
jlib:stanza_error(<<"407">>,<<"auth">>, <<"subscription-required">>). |
89 |
|
|
90 |
|
unexpected_request() -> |
91 |
:-( |
jlib:stanza_error(<<"400">>,<<"wait">>, <<"unexpected-request">>). |
92 |
|
|
93 |
|
unexpected_request_cancel() -> |
94 |
:-( |
jlib:stanza_error(<<"401">>,<<"cancel">>,<<"unexpected-request">>). |
95 |
|
|
96 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
97 |
|
%% Text Stanza Errors |
98 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
99 |
|
|
100 |
|
bad_request(Lang, Text) -> |
101 |
86 |
jlib:stanza_errort(<<"400">>,<<"modify">>,<<"bad-request">>, Lang, Text). |
102 |
|
|
103 |
|
conflict(Lang, Text) -> |
104 |
4 |
jlib:stanza_errort(<<"409">>,<<"cancel">>,<<"conflict">>, Lang, Text). |
105 |
|
|
106 |
|
feature_not_implemented(Lang, Text) -> |
107 |
203 |
jlib:stanza_errort(<<"501">>,<<"cancel">>,<<"feature-not-implemented">>, Lang, Text). |
108 |
|
|
109 |
|
forbidden(Lang, Text) -> |
110 |
17 |
jlib:stanza_errort(<<"403">>,<<"auth">>, <<"forbidden">>, Lang, Text). |
111 |
|
|
112 |
|
gone(Lang, Text) -> |
113 |
:-( |
jlib:stanza_errort(<<"302">>,<<"modify">>,<<"gone">>, Lang, Text). |
114 |
|
|
115 |
|
internal_server_error(Lang, Text) -> |
116 |
21 |
jlib:stanza_errort(<<"500">>,<<"wait">>, <<"internal-server-error">>, Lang, Text). |
117 |
|
|
118 |
|
item_not_found(Lang, Text) -> |
119 |
4 |
jlib:stanza_errort(<<"404">>,<<"cancel">>,<<"item-not-found">>, Lang, Text). |
120 |
|
|
121 |
|
jid_malformed(Lang, Text) -> |
122 |
1 |
jlib:stanza_errort(<<"400">>,<<"modify">>,<<"jid-malformed">>, Lang, Text). |
123 |
|
|
124 |
|
not_acceptable(Lang, Text) -> |
125 |
48 |
jlib:stanza_errort(<<"406">>,<<"modify">>,<<"not-acceptable">>, Lang, Text). |
126 |
|
|
127 |
|
not_allowed(Lang, Text) -> |
128 |
3 |
jlib:stanza_errort(<<"405">>,<<"cancel">>,<<"not-allowed">>, Lang, Text). |
129 |
|
|
130 |
|
not_authorized(Lang, Text) -> |
131 |
37 |
jlib:stanza_errort(<<"401">>,<<"auth">>, <<"not-authorized">>, Lang, Text). |
132 |
|
|
133 |
|
payment_required(Lang, Text) -> |
134 |
:-( |
jlib:stanza_errort(<<"402">>,<<"auth">>, <<"payment-required">>, Lang, Text). |
135 |
|
|
136 |
|
recipient_unavailable(Lang, Text) -> |
137 |
:-( |
jlib:stanza_errort(<<"404">>,<<"wait">>, <<"recipient-unavailable">>, Lang, Text). |
138 |
|
|
139 |
|
redirect(Lang, Text) -> |
140 |
:-( |
jlib:stanza_errort(<<"302">>,<<"modify">>,<<"redirect">>, Lang, Text). |
141 |
|
|
142 |
|
registration_required(Lang, Text) -> |
143 |
1 |
jlib:stanza_errort(<<"407">>,<<"auth">>, <<"registration-required">>, Lang, Text). |
144 |
|
|
145 |
|
remote_server_not_found(Lang, Text) -> |
146 |
79 |
jlib:stanza_errort(<<"404">>,<<"cancel">>,<<"remote-server-not-found">>, Lang, Text). |
147 |
|
|
148 |
|
remote_server_timeout(Lang, Text) -> |
149 |
:-( |
jlib:stanza_errort(<<"504">>,<<"wait">>, <<"remote-server-timeout">>, Lang, Text). |
150 |
|
|
151 |
|
resource_constraint(Lang, Text) -> |
152 |
17 |
jlib:stanza_errort(<<"500">>,<<"wait">>, <<"resource-constraint">>, Lang, Text). |
153 |
|
|
154 |
|
service_unavailable(Lang, Text) -> |
155 |
150 |
jlib:stanza_errort(<<"503">>,<<"cancel">>,<<"service-unavailable">>, Lang, Text). |
156 |
|
|
157 |
|
subscription_required(Lang, Text) -> |
158 |
:-( |
jlib:stanza_errort(<<"407">>,<<"auth">>, <<"subscription-required">>, Lang, Text). |
159 |
|
|
160 |
|
unexpected_request(Lang, Text) -> |
161 |
:-( |
jlib:stanza_errort(<<"400">>,<<"wait">>, <<"unexpected-request">>, Lang, Text). |
162 |
|
|
163 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
164 |
|
%% Auth Stanza Errors |
165 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
166 |
|
|
167 |
|
auth_no_resource_provided(Lang) -> |
168 |
:-( |
not_acceptable(Lang,<<"No resource provided">>). |
169 |
|
|
170 |
|
auth_bad_resource_format(Lang) -> |
171 |
:-( |
not_acceptable(Lang,<<"Illegal resource format">>). |
172 |
|
|
173 |
|
auth_resource_conflict(Lang) -> |
174 |
:-( |
conflict(Lang, <<"Resource conflict">>). |
175 |
|
|
176 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
177 |
|
%% Stream Errors |
178 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
179 |
|
|
180 |
|
bad_format() -> |
181 |
:-( |
jlib:stream_error(<<"bad-format">>). |
182 |
|
|
183 |
|
bad_namespace_prefix() -> |
184 |
:-( |
jlib:stream_error(<<"bad-namespace-prefix">>). |
185 |
|
|
186 |
|
stream_conflict() -> |
187 |
15 |
jlib:stream_error(<<"conflict">>). |
188 |
|
|
189 |
|
connection_timeout() -> |
190 |
:-( |
jlib:stream_error(<<"connection-timeout">>). |
191 |
|
|
192 |
|
host_gone() -> |
193 |
:-( |
jlib:stream_error(<<"host-gone">>). |
194 |
|
|
195 |
|
host_unknown() -> |
196 |
3 |
jlib:stream_error(<<"host-unknown">>). |
197 |
|
|
198 |
|
improper_addressing() -> |
199 |
:-( |
jlib:stream_error(<<"improper-addressing">>). |
200 |
|
|
201 |
|
stream_internal_server_error() -> |
202 |
:-( |
jlib:stream_error(<<"internal-server-error">>). |
203 |
|
|
204 |
|
invalid_from() -> |
205 |
4 |
jlib:stream_error(<<"invalid-from">>). |
206 |
|
|
207 |
|
invalid_id() -> |
208 |
:-( |
jlib:stream_error(<<"invalid-id">>). |
209 |
|
|
210 |
|
invalid_namespace() -> |
211 |
5 |
jlib:stream_error(<<"invalid-namespace">>). |
212 |
|
|
213 |
|
invalid_xml() -> |
214 |
2 |
jlib:stream_error(<<"invalid-xml">>). |
215 |
|
|
216 |
|
stream_not_authorized() -> |
217 |
:-( |
jlib:stream_error(<<"not-authorized">>). |
218 |
|
|
219 |
|
policy_violation() -> |
220 |
7 |
jlib:stream_error(<<"policy-violation">>). |
221 |
|
|
222 |
|
remote_connection_failed() -> |
223 |
:-( |
jlib:stream_error(<<"remote-connection-failed">>). |
224 |
|
|
225 |
|
stream_resource_constraint() -> |
226 |
:-( |
jlib:stream_error(<<"resource-constraint">>). |
227 |
|
|
228 |
|
restricted_xml() -> |
229 |
:-( |
jlib:stream_error(<<"restricted-xml">>). |
230 |
|
|
231 |
|
% TODO: include hostname or IP |
232 |
|
see_other_host() -> |
233 |
:-( |
jlib:stream_error(<<"see-other-host">>). |
234 |
|
|
235 |
|
system_shutdown() -> |
236 |
3 |
jlib:stream_error(<<"system-shutdown">>). |
237 |
|
|
238 |
|
unsupported_encoding() -> |
239 |
:-( |
jlib:stream_error(<<"unsupported-encoding">>). |
240 |
|
|
241 |
|
unsupported_stanza_type() -> |
242 |
:-( |
jlib:stream_error(<<"unsupported-stanza-type">>). |
243 |
|
|
244 |
|
unsupported_version() -> |
245 |
2 |
jlib:stream_error(<<"unsupported-version">>). |
246 |
|
|
247 |
|
xml_not_well_formed() -> |
248 |
7 |
jlib:stream_error(<<"xml-not-well-formed">>). |
249 |
|
|
250 |
|
undefined_condition() -> |
251 |
:-( |
jlib:stream_error(<<"undefined-condition">>). |
252 |
|
|
253 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
254 |
|
%% Text Stream Errors |
255 |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
256 |
|
|
257 |
|
bad_format(Lang, Text) -> |
258 |
:-( |
jlib:stream_errort(<<"bad-format">>, Lang, Text). |
259 |
|
|
260 |
|
bad_namespace_prefix(Lang, Text) -> |
261 |
:-( |
jlib:stream_errort(<<"bad-namespace-prefix">>, Lang, Text). |
262 |
|
|
263 |
|
stream_conflict(Lang, Text) -> |
264 |
173 |
jlib:stream_errort(<<"conflict">>, Lang, Text). |
265 |
|
|
266 |
|
connection_timeout(Lang, Text) -> |
267 |
:-( |
jlib:stream_errort(<<"connection-timeout">>, Lang, Text). |
268 |
|
|
269 |
|
host_gone(Lang, Text) -> |
270 |
:-( |
jlib:stream_errort(<<"host-gone">>, Lang, Text). |
271 |
|
|
272 |
|
host_unknown(Lang, Text) -> |
273 |
1 |
jlib:stream_errort(<<"host-unknown">>, Lang, Text). |
274 |
|
|
275 |
|
improper_addressing(Lang, Text) -> |
276 |
1 |
jlib:stream_errort(<<"improper-addressing">>, Lang, Text). |
277 |
|
|
278 |
|
stream_internal_server_error(Lang, Text) -> |
279 |
:-( |
jlib:stream_errort(<<"internal-server-error">>, Lang, Text). |
280 |
|
|
281 |
|
invalid_from(Lang, Text) -> |
282 |
:-( |
jlib:stream_errort(<<"invalid-from">>, Lang, Text). |
283 |
|
|
284 |
|
invalid_id(Lang, Text) -> |
285 |
:-( |
jlib:stream_errort(<<"invalid-id">>, Lang, Text). |
286 |
|
|
287 |
|
invalid_namespace(Lang, Text) -> |
288 |
:-( |
jlib:stream_errort(<<"invalid-namespace">>, Lang, Text). |
289 |
|
|
290 |
|
invalid_xml(Lang, Text) -> |
291 |
:-( |
jlib:stream_errort(<<"invalid-xml">>, Lang, Text). |
292 |
|
|
293 |
|
stream_not_authorized(Lang, Text) -> |
294 |
:-( |
jlib:stream_errort(<<"not-authorized">>, Lang, Text). |
295 |
|
|
296 |
|
policy_violation(Lang, Text) -> |
297 |
10 |
jlib:stream_errort(<<"policy-violation">>, Lang, Text). |
298 |
|
|
299 |
|
remote_connection_failed(Lang, Text) -> |
300 |
:-( |
jlib:stream_errort(<<"remote-connection-failed">>, Lang, Text). |
301 |
|
|
302 |
|
stream_resource_constraint(Lang, Text) -> |
303 |
2 |
jlib:stream_errort(<<"resource-constraint">>, Lang, Text). |
304 |
|
|
305 |
|
restricted_xml(Lang, Text) -> |
306 |
:-( |
jlib:stream_errort(<<"restricted-xml">>, Lang, Text). |
307 |
|
|
308 |
|
% TODO: include hostname or IP |
309 |
|
see_other_host(Lang, Text) -> |
310 |
:-( |
jlib:stream_errort(<<"see-other-host">>, Lang, Text). |
311 |
|
|
312 |
|
system_shutdown(Lang, Text) -> |
313 |
:-( |
jlib:stream_errort(<<"system-shutdown">>, Lang, Text). |
314 |
|
|
315 |
|
unsupported_encoding(Lang, Text) -> |
316 |
:-( |
jlib:stream_errort(<<"unsupported-encoding">>, Lang, Text). |
317 |
|
|
318 |
|
unsupported_stanza_type(Lang, Text) -> |
319 |
:-( |
jlib:stream_errort(<<"unsupported-stanza-type">>, Lang, Text). |
320 |
|
|
321 |
|
unsupported_version(Lang, Text) -> |
322 |
:-( |
jlib:stream_errort(<<"unsupported-version">>, Lang, Text). |
323 |
|
|
324 |
|
xml_not_well_formed(Lang, Text) -> |
325 |
:-( |
jlib:stream_errort(<<"xml-not-well-formed">>, Lang, Text). |
326 |
|
|
327 |
|
xml_not_well_formed_bin() -> |
328 |
:-( |
exml:to_binary(xml_not_well_formed()). |
329 |
|
|
330 |
|
undefined_condition(Lang, Text) -> |
331 |
4 |
jlib:stream_errort(<<"undefined-condition">>, Lang, Text). |
332 |
|
|
333 |
|
bad_format_bin() -> |
334 |
:-( |
exml:to_binary(bad_format()). |