0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

modules/client/profile: Return better errors to client for remote profile requests.

This commit is contained in:
Jason Volk 2019-03-01 13:49:19 -08:00
parent 4612fc6058
commit 452c664a8c

View file

@ -236,6 +236,7 @@ resource::response
get__profile_remote(client &client,
const resource::request &request,
const m::user &user)
try
{
//TODO: XXX cache strat user's room
@ -260,9 +261,12 @@ get__profile_remote(client &client,
//TODO: conf
if(!federation_request.wait(seconds(8), std::nothrow))
throw http::error
throw m::error
{
http::REQUEST_TIMEOUT
http::GATEWAY_TIMEOUT, "M_PROFILE_TIMEOUT",
"Server '%s' did not respond with profile for %s in time.",
user.user_id.host(),
string_view{user.user_id}
};
const http::code &code
@ -282,6 +286,32 @@ get__profile_remote(client &client,
client, response
};
}
catch(const http::error &)
{
throw;
}
catch(const server::unavailable &e)
{
throw m::error
{
http::SERVICE_UNAVAILABLE, "M_PROFILE_UNAVAILABLE",
"Server '%s' cannot be contacted for profile of %s :%s",
user.user_id.host(),
string_view{user.user_id},
e.what()
};
}
catch(const server::error &e)
{
throw m::error
{
http::BAD_GATEWAY, "M_PROFILE_UNAVAILABLE",
"Error when contacting '%s' for profile of %s :%s",
user.user_id.host(),
string_view{user.user_id},
e.what()
};
}
m::event::id::buf
IRCD_MODULE_EXPORT