fix(slurm): parse structured errors from non-2xx Slurm API responses

Replace ErrorResponse with SlurmAPIError that extracts structured errors/warnings from JSON body when Slurm returns non-2xx (e.g. 404 with valid JSON). Add IsNotFound helper for fallback logic.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-10 13:43:17 +08:00
parent 30f0fbc34b
commit b3d787c97b
3 changed files with 284 additions and 17 deletions

View File

@@ -137,11 +137,11 @@ func TestClient_ErrorHandling(t *testing.T) {
t.Fatal("expected error for 500 response")
}
errorResp, ok := err.(*ErrorResponse)
errorResp, ok := err.(*SlurmAPIError)
if !ok {
t.Fatalf("expected *ErrorResponse, got %T", err)
t.Fatalf("expected *SlurmAPIError, got %T", err)
}
if errorResp.Response.StatusCode != 500 {
t.Errorf("expected status 500, got %d", errorResp.Response.StatusCode)
if errorResp.StatusCode != 500 {
t.Errorf("expected status 500, got %d", errorResp.StatusCode)
}
}