Refactor cloud requirements error and surface in JSON-RPC error (#14504)

Refactors cloud requirements error handling to carry structured error
metadata and surfaces that metadata through JSON-RPC config-load
failures, including:
* adds typed CloudRequirementsLoadErrorCode values plus optional
statusCode
* marks thread/start, thread/resume, and thread/fork config failures
with structured cloud-requirements error data
This commit is contained in:
alexsong-oai
2026-03-12 20:30:51 -07:00
committed by GitHub
parent 0daffe667a
commit 650beb177e
9 changed files with 562 additions and 29 deletions

View File

@@ -6,18 +6,43 @@ use std::fmt;
use std::future::Future;
use thiserror::Error;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CloudRequirementsLoadErrorCode {
Auth,
Timeout,
Parse,
RequestFailed,
Internal,
}
#[derive(Clone, Debug, Eq, Error, PartialEq)]
#[error("{message}")]
pub struct CloudRequirementsLoadError {
code: CloudRequirementsLoadErrorCode,
message: String,
status_code: Option<u16>,
}
impl CloudRequirementsLoadError {
pub fn new(message: impl Into<String>) -> Self {
pub fn new(
code: CloudRequirementsLoadErrorCode,
status_code: Option<u16>,
message: impl Into<String>,
) -> Self {
Self {
code,
message: message.into(),
status_code,
}
}
pub fn code(&self) -> CloudRequirementsLoadErrorCode {
self.code
}
pub fn status_code(&self) -> Option<u16> {
self.status_code
}
}
#[derive(Clone)]