mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
modules/media: Throw better http codes for downloading media.
This commit is contained in:
parent
8c61f6370a
commit
80743b2fd5
1 changed files with 16 additions and 4 deletions
|
@ -251,9 +251,15 @@ try
|
|||
}
|
||||
catch(const ircd::server::unavailable &e)
|
||||
{
|
||||
throw http::error
|
||||
thread_local char rembuf[256];
|
||||
throw m::error
|
||||
{
|
||||
http::BAD_GATEWAY, e.what()
|
||||
http::BAD_GATEWAY, "M_MEDIA_UNAVAILABLE",
|
||||
"Server '%s' is not available for media for '%s/%s' :%s",
|
||||
string(rembuf, remote),
|
||||
server,
|
||||
mediaid,
|
||||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -271,6 +277,8 @@ download(const mutable_buffer &head_buf,
|
|||
net::hostport remote,
|
||||
server::request::opts *const opts)
|
||||
{
|
||||
thread_local char rembuf[256];
|
||||
|
||||
if(!remote)
|
||||
remote = server;
|
||||
|
||||
|
@ -304,9 +312,13 @@ download(const mutable_buffer &head_buf,
|
|||
};
|
||||
|
||||
if(!remote_request.wait(seconds(media_download_timeout), std::nothrow))
|
||||
throw http::error
|
||||
throw m::error
|
||||
{
|
||||
http::REQUEST_TIMEOUT
|
||||
http::GATEWAY_TIMEOUT, "M_MEDIA_DOWNLOAD_TIMEOUT",
|
||||
"Server '%s' did not respond with media for '%s/%s' in time",
|
||||
string(rembuf, remote),
|
||||
server,
|
||||
mediaid
|
||||
};
|
||||
|
||||
const auto &code
|
||||
|
|
Loading…
Reference in a new issue