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

Function extractErrorMessage

apps/sim/tools/whatsapp/utils.ts:36–46  ·  view source on GitHub ↗

Extract a human-readable error message from a WhatsApp API error payload.

(data: Record<string, unknown>, status: number)

Source from the content-addressed store, hash-verified

34
35/** Extract a human-readable error message from a WhatsApp API error payload. */
36function extractErrorMessage(data: Record<string, unknown>, status: number): string {
37 const error = isRecord(data.error) ? data.error : undefined
38 return (
39 (typeof error?.message === 'string' ? error.message : undefined) ||
40 (typeof error?.error_user_msg === 'string' ? error.error_user_msg : undefined) ||
41 (isRecord(error?.error_data) && typeof error.error_data.details === 'string'
42 ? error.error_data.details
43 : undefined) ||
44 `WhatsApp API error (${status})`
45 )
46}
47
48/**
49 * Transform the shared send response shape returned by every outbound message

Callers 1

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected