| 331 | } |
| 332 | |
| 333 | func StatusForBundleError(err error) int { |
| 334 | switch { |
| 335 | case err == nil: |
| 336 | return http.StatusOK |
| 337 | case errors.Is(err, bundlepkg.ErrActivationNotFound), |
| 338 | errors.Is(err, bundlepkg.ErrBundleNotFound), |
| 339 | errors.Is(err, bundlepkg.ErrProfileNotFound), |
| 340 | errors.Is(err, extensionpkg.ErrExtensionNotFound): |
| 341 | return http.StatusNotFound |
| 342 | case errors.Is(err, bundlepkg.ErrDefaultChannelBusy), |
| 343 | errors.Is(err, bundlepkg.ErrAgentConflict), |
| 344 | errors.Is(err, extensionpkg.ErrExtensionHasActiveBundles): |
| 345 | return http.StatusConflict |
| 346 | case errors.Is(err, bundlepkg.ErrAgentReferenceNotFound): |
| 347 | return http.StatusUnprocessableEntity |
| 348 | case errors.Is(err, bundlepkg.ErrWebhookUnsupported): |
| 349 | return http.StatusBadRequest |
| 350 | case errors.Is(err, workspacepkg.ErrWorkspaceNotFound), |
| 351 | errors.Is(err, workspacepkg.ErrWorkspaceRootMissing): |
| 352 | return StatusForWorkspaceError(err) |
| 353 | default: |
| 354 | return http.StatusInternalServerError |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | func bundlepkgStableID(prefix string, parts ...string) string { |
| 359 | normalized := make([]string, 0, len(parts)) |