MCPcopy Index your code
hub / github.com/simstudioai/sim / extractZoomInfoError

Function extractZoomInfoError

apps/sim/app/api/tools/zoominfo/shared.ts:171–204  ·  view source on GitHub ↗
(body: unknown, status: number)

Source from the content-addressed store, hash-verified

169}
170
171export function extractZoomInfoError(body: unknown, status: number): string {
172 if (body && typeof body === 'object') {
173 const obj = body as Record<string, unknown>
174 if (obj.error && typeof obj.error === 'object') {
175 const eo = obj.error as Record<string, unknown>
176 const message = typeof eo.message === 'string' ? eo.message : ''
177 const code = typeof eo.code === 'string' ? eo.code : ''
178 if (message) return code ? `[${code}] ${message}` : message
179 }
180 if (typeof obj.error === 'string' && obj.error.length > 0) {
181 const desc = typeof obj.error_description === 'string' ? `: ${obj.error_description}` : ''
182 return `${obj.error}${desc}`
183 }
184 if (typeof obj.message === 'string' && obj.message.length > 0) {
185 return obj.message
186 }
187 if (Array.isArray(obj.errors) && obj.errors.length > 0) {
188 return obj.errors
189 .map((e) => {
190 if (e && typeof e === 'object') {
191 const eo = e as Record<string, unknown>
192 const title = typeof eo.title === 'string' ? eo.title : ''
193 const detail = typeof eo.detail === 'string' ? `: ${eo.detail}` : ''
194 return `${title}${detail}`.trim()
195 }
196 return String(e)
197 })
198 .filter(Boolean)
199 .join('; ')
200 }
201 }
202 if (typeof body === 'string' && body.length > 0) return body
203 return `ZoomInfo request failed with HTTP ${status}`
204}

Callers 1

route.tsFile · 0.90

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected