mirror of
https://github.com/baz-scm/awesome-reviewers.git
synced 2025-08-20 18:58:52 +03:00
46 lines
4.6 KiB
JSON
46 lines
4.6 KiB
JSON
[
|
|
{
|
|
"discussion_id": "2266647379",
|
|
"pr_number": 36401,
|
|
"pr_file": "rust/batch-import-worker/src/error/mod.rs",
|
|
"created_at": "2025-08-11T12:53:34+00:00",
|
|
"commented_code": "DEFAULT_USER_ERROR_MESSAGE\n }\n \n+#[derive(Error, Debug)]\n+#[error(\"Rate limited\")]\n+pub struct RateLimitedError {\n+ pub retry_after: Option<Duration>,\n+ #[source]\n+ pub source: reqwest::Error,\n+}\n+\n+/// Extracts a Retry-After duration if a RateLimitedError is present in the error chain\n+pub fn extract_retry_after_from_error(error: &anyhow::Error) -> Option<Duration> {",
|
|
"repo_full_name": "PostHog/posthog",
|
|
"discussion_comments": [
|
|
{
|
|
"comment_id": "2266647379",
|
|
"repo_full_name": "PostHog/posthog",
|
|
"pr_number": 36401,
|
|
"pr_file": "rust/batch-import-worker/src/error/mod.rs",
|
|
"discussion_id": "2266647379",
|
|
"commented_code": "@@ -42,10 +43,61 @@ pub fn get_user_message(error: &anyhow::Error) -> &str {\n DEFAULT_USER_ERROR_MESSAGE\n }\n \n+#[derive(Error, Debug)]\n+#[error(\"Rate limited\")]\n+pub struct RateLimitedError {\n+ pub retry_after: Option<Duration>,\n+ #[source]\n+ pub source: reqwest::Error,\n+}\n+\n+/// Extracts a Retry-After duration if a RateLimitedError is present in the error chain\n+pub fn extract_retry_after_from_error(error: &anyhow::Error) -> Option<Duration> {",
|
|
"comment_created_at": "2025-08-11T12:53:34+00:00",
|
|
"comment_author": "jose-sequeira",
|
|
"comment_body": "Think using `chain()` iterator is more straightforward than managing source()\n\n```suggestion\npub fn extract_retry_after_from_error(error: &anyhow::Error) -> Option<Duration> {\n error\n .chain()\n .find_map(|e| e.downcast_ref::<RateLimitedError>())\n .and_then(|rl| rl.retry_after)\n}\n```",
|
|
"pr_file_module": null
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"discussion_id": "2266650106",
|
|
"pr_number": 36401,
|
|
"pr_file": "rust/batch-import-worker/src/error/mod.rs",
|
|
"created_at": "2025-08-11T12:54:37+00:00",
|
|
"commented_code": "DEFAULT_USER_ERROR_MESSAGE\n }\n \n+#[derive(Error, Debug)]\n+#[error(\"Rate limited\")]\n+pub struct RateLimitedError {\n+ pub retry_after: Option<Duration>,\n+ #[source]\n+ pub source: reqwest::Error,\n+}\n+\n+/// Extracts a Retry-After duration if a RateLimitedError is present in the error chain\n+pub fn extract_retry_after_from_error(error: &anyhow::Error) -> Option<Duration> {\n+ if let Some(rl) = error.downcast_ref::<RateLimitedError>() {\n+ return rl.retry_after;\n+ }\n+\n+ let mut source = error.source();\n+ while let Some(err) = source {\n+ if let Some(rl) = err.downcast_ref::<RateLimitedError>() {\n+ return rl.retry_after;\n+ }\n+ source = err.source();\n+ }\n+ None\n+}\n+\n+/// Returns true if the error chain contains a reqwest::Error with HTTP 429.\n+pub fn is_rate_limited_error(error: &anyhow::Error) -> bool {",
|
|
"repo_full_name": "PostHog/posthog",
|
|
"discussion_comments": [
|
|
{
|
|
"comment_id": "2266650106",
|
|
"repo_full_name": "PostHog/posthog",
|
|
"pr_number": 36401,
|
|
"pr_file": "rust/batch-import-worker/src/error/mod.rs",
|
|
"discussion_id": "2266650106",
|
|
"commented_code": "@@ -42,10 +43,61 @@ pub fn get_user_message(error: &anyhow::Error) -> &str {\n DEFAULT_USER_ERROR_MESSAGE\n }\n \n+#[derive(Error, Debug)]\n+#[error(\"Rate limited\")]\n+pub struct RateLimitedError {\n+ pub retry_after: Option<Duration>,\n+ #[source]\n+ pub source: reqwest::Error,\n+}\n+\n+/// Extracts a Retry-After duration if a RateLimitedError is present in the error chain\n+pub fn extract_retry_after_from_error(error: &anyhow::Error) -> Option<Duration> {\n+ if let Some(rl) = error.downcast_ref::<RateLimitedError>() {\n+ return rl.retry_after;\n+ }\n+\n+ let mut source = error.source();\n+ while let Some(err) = source {\n+ if let Some(rl) = err.downcast_ref::<RateLimitedError>() {\n+ return rl.retry_after;\n+ }\n+ source = err.source();\n+ }\n+ None\n+}\n+\n+/// Returns true if the error chain contains a reqwest::Error with HTTP 429.\n+pub fn is_rate_limited_error(error: &anyhow::Error) -> bool {",
|
|
"comment_created_at": "2025-08-11T12:54:37+00:00",
|
|
"comment_author": "jose-sequeira",
|
|
"comment_body": "Same for here, this can be simplified\n\n```\n error.chain().any(|e| {\n e.is::<RateLimitedError>()\n || (e\n .downcast_ref::<reqwest::Error>()\n .and_then(|re| re.status())\n == Some(StatusCode::TOO_MANY_REQUESTS))\n })\n```",
|
|
"pr_file_module": null
|
|
}
|
|
]
|
|
}
|
|
] |