use serde_json::Value;
use super::DispatchError;
pub(super) fn classify(finish: &Value) -> Option<DispatchError> {
if finish.get("type").and_then(Value::as_str) != Some("abort") {
return None;
}
let status = finish.get("status_code").and_then(Value::as_u64);
Some(if status == Some(429) {
DispatchError {
status: super::super::error::overload_status_code(),
public_message: "SGLang scoring worker capacity is exhausted",
detail: "native scoring worker capacity exhausted".to_string(),
retry_after: true,
is_capacity_exhausted: true,
}
} else {
DispatchError {
retry_after: status == Some(503),
..DispatchError::unavailable("native scoring worker aborted")
}
})
}