MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / handleErrorResponse

Method handleErrorResponse

packages/cloud/src/CloudAPI.ts:85–109  ·  view source on GitHub ↗
(response: Response, endpoint: string)

Source from the content-addressed store, hash-verified

83 }
84
85 private async handleErrorResponse(response: Response, endpoint: string): Promise<never> {
86 let responseBody: unknown
87
88 try {
89 responseBody = await response.json()
90 } catch {
91 responseBody = await response.text()
92 }
93
94 switch (response.status) {
95 case 401:
96 throw new AuthenticationError()
97 case 404:
98 if (endpoint.includes("/share")) {
99 throw new TaskNotFoundError()
100 }
101 throw new CloudAPIError(`Resource not found: ${endpoint}`, 404, responseBody)
102 default:
103 throw new CloudAPIError(
104 `HTTP ${response.status}: ${response.statusText}`,
105 response.status,
106 responseBody,
107 )
108 }
109 }
110
111 async shareTask(taskId: string, visibility: ShareVisibility = "organization"): Promise<ShareResponse> {
112 this.log(`[CloudAPI] Sharing task ${taskId} with visibility: ${visibility}`)

Callers 1

requestMethod · 0.95

Calls 1

textMethod · 0.80

Tested by

no test coverage detected