Skip to content
Snippets Groups Projects
Verified Commit b3740e26 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Support retry timeouts

parent 8dd9214f
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
/// @file
/// @brief The error struct returned by the Matrix API.
#include <chrono>
#include "lightweight_error.hpp"
#include "user_interactive.hpp"
......@@ -19,6 +21,9 @@ struct Error
//! Auth flows in case of 401
user_interactive::Unauthorized unauthorized;
//! Retry delay in case of 429
std::chrono::duration<std::uint64_t, std::milli> retry_after;
friend void from_json(const nlohmann::json &obj, Error &error);
};
}
......
......@@ -111,6 +111,10 @@ from_json(const nlohmann::json &obj, Error &error)
if (obj.contains("flows"))
error.unauthorized = obj.get<user_interactive::Unauthorized>();
if (obj.contains("retry_after_ms"))
error.retry_after =
std::chrono::milliseconds(obj.value("retry_after_ms", std::uint64_t{0}));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment