0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-10 12:38:36 +02:00

modules/client: Update various thrown errors.

This commit is contained in:
Jason Volk 2018-02-14 21:54:07 -08:00
parent 38454022cd
commit 9da8e233d6
4 changed files with 15 additions and 15 deletions

View file

@ -62,15 +62,15 @@ post_login_password(client &client,
}; };
if(!user.is_password(supplied_password)) if(!user.is_password(supplied_password))
throw m::error throw m::FORBIDDEN
{ {
http::FORBIDDEN, "M_FORBIDDEN", "Access denied." "Access denied."
}; };
if(!user.is_active()) if(!user.is_active())
throw m::error throw m::FORBIDDEN
{ {
http::FORBIDDEN, "M_FORBIDDEN", "Access denied." "Access denied."
}; };
// Generate the access token // Generate the access token

View file

@ -52,9 +52,9 @@ try
// We only support this for now, for some reason. TODO: XXX // We only support this for now, for some reason. TODO: XXX
if(type && type != "m.login.dummy") if(type && type != "m.login.dummy")
throw m::error throw m::UNSUPPORTED
{ {
"M_UNSUPPORTED", "Registration '%s' not supported.", type "Registration '%s' not supported.", type
}; };
// 3.3.1 The local part of the desired Matrix ID. If omitted, the homeserver MUST // 3.3.1 The local part of the desired Matrix ID. If omitted, the homeserver MUST
@ -126,8 +126,7 @@ catch(const m::INVALID_MXID &e)
{ {
throw m::error throw m::error
{ {
http::BAD_REQUEST, http::BAD_REQUEST, "M_INVALID_USERNAME",
"M_INVALID_USERNAME",
"Not a valid username. Please try again." "Not a valid username. Please try again."
}; };
}; };
@ -167,10 +166,8 @@ handle_post(client &client,
if(kind.empty() || kind == "user") if(kind.empty() || kind == "user")
return handle_post_kind_user(client, request); return handle_post_kind_user(client, request);
throw m::error throw m::UNSUPPORTED
{ {
http::BAD_REQUEST,
"M_UNKNOWN",
"Unknown 'kind' of registration specified in query." "Unknown 'kind' of registration specified in query."
}; };
} }

View file

@ -96,7 +96,10 @@ put_rooms(client &client, const resource::request &request)
if(cmd == "typing") if(cmd == "typing")
return put__typing(client, request, room_id); return put__typing(client, request, room_id);
throw m::NOT_FOUND{"/rooms command not found"}; throw m::NOT_FOUND
{
"/rooms command not found"
};
} }
resource::method resource::method
@ -137,9 +140,9 @@ post_rooms(client &client,
if(cmd == "join") if(cmd == "join")
return post__join(client, request, room_id); return post__join(client, request, room_id);
throw m::error throw m::NOT_FOUND
{ {
http::MULTIPLE_CHOICES, "M_NOT_FOUND", "/rooms command required" "/rooms command not found"
}; };
} }

View file

@ -46,7 +46,7 @@ post__filter(client &client,
// (5.2) Required. The id of the user uploading the filter. The access // (5.2) Required. The id of the user uploading the filter. The access
// token must be authorized to make requests for this user id. // token must be authorized to make requests for this user id.
if(user_id != request.user_id) if(user_id != request.user_id)
throw m::ACCESS_DENIED throw m::FORBIDDEN
{ {
"Trying to post a filter for `%s' but you are `%s'", "Trying to post a filter for `%s' but you are `%s'",
user_id, user_id,