( response: Response, data: unknown, fallback: string )
| 231 | } |
| 232 | |
| 233 | export function extractTrelloErrorMessage( |
| 234 | response: Response, |
| 235 | data: unknown, |
| 236 | fallback: string |
| 237 | ): string { |
| 238 | const parts: string[] = [] |
| 239 | |
| 240 | if (isRecordLike(data)) { |
| 241 | const message = data.message |
| 242 | const error = data.error |
| 243 | |
| 244 | if (typeof message === 'string' && message.trim().length > 0) { |
| 245 | parts.push(message) |
| 246 | } |
| 247 | |
| 248 | if (typeof error === 'string' && error.trim().length > 0 && error !== message) { |
| 249 | parts.push(error) |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | if (parts.length > 0) { |
| 254 | return `${fallback}: ${parts.join(' - ')}` |
| 255 | } |
| 256 | |
| 257 | if (response.statusText) { |
| 258 | return `${fallback}: ${response.status} ${response.statusText}` |
| 259 | } |
| 260 | |
| 261 | return fallback |
| 262 | } |
no test coverage detected