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