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

Function parseGraphErrorMessage

apps/sim/tools/microsoft_excel/utils.ts:77–102  ·  view source on GitHub ↗
(
  status: number,
  statusText: string,
  errorText: string
)

Source from the content-addressed store, hash-verified

75 * Used by API routes that have a Response object rather than parsed data.
76 */
77export function parseGraphErrorMessage(
78 status: number,
79 statusText: string,
80 errorText: string
81): string {
82 try {
83 const data = JSON.parse(errorText)
84 const message = parseGraphErrorFromData(data)
85 if (message) {
86 // If the only thing we found was the bare error code, append status for context.
87 const root = data?.error
88 if (
89 root &&
90 message === root.code?.trim?.() &&
91 !(typeof root.message === 'string' && root.message.trim())
92 ) {
93 return `${message} (${status} ${statusText})`
94 }
95 return message
96 }
97 } catch {
98 if (errorText?.trim()) return errorText.trim()
99 }
100
101 return statusText ? `${status} ${statusText}` : `Microsoft Graph request failed (${status})`
102}
103
104/**
105 * Read an error response body and produce a developer-readable message.

Callers 4

utils.test.tsFile · 0.90
format_range.tsFile · 0.90
read.tsFile · 0.90
extractGraphErrorFunction · 0.85

Calls 2

parseGraphErrorFromDataFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected