You've already forked agentic-coding-workflow
feat(jobs): migration 0005 + errs codes for jobs module
This commit is contained in:
@@ -66,6 +66,13 @@ const (
|
||||
// Storage 域
|
||||
CodeStoragePutFailed Code = "storage.put_failed"
|
||||
CodeStorageGetFailed Code = "storage.get_failed"
|
||||
|
||||
// Jobs 域
|
||||
CodeJobNotFound Code = "job.not_found"
|
||||
CodeJobInvalidType Code = "job.invalid_type"
|
||||
CodeJobPayloadInvalid Code = "job.payload_invalid"
|
||||
CodeJobPayloadTooLarge Code = "job.payload_too_large"
|
||||
CodeWebhookNotConfigured Code = "webhook.not_configured"
|
||||
)
|
||||
|
||||
// AppError is the application's structured error type. It carries a stable
|
||||
@@ -171,6 +178,12 @@ func HTTPStatus(code Code) int {
|
||||
return http.StatusBadGateway
|
||||
case CodeLLMContextTooLong:
|
||||
return http.StatusBadRequest
|
||||
case CodeJobNotFound:
|
||||
return http.StatusNotFound
|
||||
case CodeJobInvalidType, CodeJobPayloadInvalid, CodeJobPayloadTooLarge:
|
||||
return http.StatusBadRequest
|
||||
case CodeWebhookNotConfigured:
|
||||
return http.StatusServiceUnavailable
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
|
||||
@@ -70,6 +70,12 @@ func TestHTTPStatus(t *testing.T) {
|
||||
// Storage codes
|
||||
CodeStoragePutFailed: http.StatusBadGateway,
|
||||
CodeStorageGetFailed: http.StatusBadGateway,
|
||||
// Jobs codes
|
||||
CodeJobNotFound: http.StatusNotFound,
|
||||
CodeJobInvalidType: http.StatusBadRequest,
|
||||
CodeJobPayloadInvalid: http.StatusBadRequest,
|
||||
CodeJobPayloadTooLarge: http.StatusBadRequest,
|
||||
CodeWebhookNotConfigured: http.StatusServiceUnavailable,
|
||||
}
|
||||
for code, want := range cases {
|
||||
require.Equal(t, want, HTTPStatus(code), "code=%s", code)
|
||||
|
||||
Reference in New Issue
Block a user