# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1660569974 -7200
# Node ID 732229fe68ab0a3566cca63d756c226134a6b2d1
# Parent  8a8ec909ac20f19d3283323954b011b644381a7c
mod_rest: Fill in 'type' field in error registry

The 'type' defaults to "modify" in util.error, which doesn't quite fit
many of these error conditions.

LuaFormatter changed ',' to ';'

diff -r 8a8ec909ac20 -r 732229fe68ab mod_rest/mod_rest.lua
--- a/mod_rest/mod_rest.lua	Fri Aug 12 17:15:11 2022 +0200
+++ b/mod_rest/mod_rest.lua	Mon Aug 15 15:26:14 2022 +0200
@@ -262,17 +262,17 @@
 end
 
 local post_errors = errors.init("mod_rest", {
-	noauthz = { code = 401, type = "auth", condition = "not-authorized", text = "No credentials provided" },
-	unauthz = { code = 403, type = "auth", condition = "not-authorized", text = "Credentials not accepted" },
-	parse = { code = 400, condition = "not-well-formed", text = "Failed to parse payload", },
-	xmlns = { code = 422, condition = "invalid-namespace", text = "'xmlns' attribute must be empty", },
-	name = { code = 422, condition = "unsupported-stanza-type", text = "Invalid stanza, must be 'message', 'presence' or 'iq'.", },
-	to = { code = 422, condition = "improper-addressing", text = "Invalid destination JID", },
-	from = { code = 422, condition = "invalid-from", text = "Invalid source JID", },
-	from_auth = { code = 403, condition = "not-authorized", text = "Not authorized to send stanza with requested 'from'", },
-	iq_type = { code = 422, condition = "invalid-xml", text = "'iq' stanza must be of type 'get' or 'set'", },
-	iq_tags = { code = 422, condition = "bad-format", text = "'iq' stanza must have exactly one child tag", },
-	mediatype = { code = 415, condition = "bad-format", text = "Unsupported media type" },
+	noauthz = { code = 401; type = "auth"; condition = "not-authorized"; text = "No credentials provided" };
+	unauthz = { code = 403; type = "auth"; condition = "not-authorized"; text = "Credentials not accepted" };
+	parse = { code = 400; type = "modify"; condition = "not-well-formed"; text = "Failed to parse payload" };
+	xmlns = { code = 422; type = "modify"; condition = "invalid-namespace"; text = "'xmlns' attribute must be empty" };
+	name = { code = 422; type = "modify"; condition = "unsupported-stanza-type"; text = "Invalid stanza, must be 'message', 'presence' or 'iq'." };
+	to = { code = 422; type = "modify"; condition = "improper-addressing"; text = "Invalid destination JID" };
+	from = { code = 422; type = "modify"; condition = "invalid-from"; text = "Invalid source JID" };
+	from_auth = { code = 403; type = "auth"; condition = "not-authorized"; text = "Not authorized to send stanza with requested 'from'" };
+	iq_type = { code = 422; type = "modify"; condition = "invalid-xml"; text = "'iq' stanza must be of type 'get' or 'set'" };
+	iq_tags = { code = 422; type = "modify"; condition = "bad-format"; text = "'iq' stanza must have exactly one child tag" };
+	mediatype = { code = 415; type = "cancel"; condition = "bad-format"; text = "Unsupported media type" };
 });
 
 -- GET → iq-get