* Transform error messages from the gateway to be more user-friendly.
(message: string, host: string)
| 38 | * Transform error messages from the gateway to be more user-friendly. |
| 39 | */ |
| 40 | function transformErrorMessage(message: string, host: string): string { |
| 41 | if (message.includes('gateway token missing') || message.includes('gateway token mismatch')) { |
| 42 | return `Invalid or missing token. Visit https://${host}?token={REPLACE_WITH_YOUR_TOKEN}`; |
| 43 | } |
| 44 | |
| 45 | if (message.includes('pairing required')) { |
| 46 | return `Pairing required. Visit https://${host}/_admin/`; |
| 47 | } |
| 48 | |
| 49 | return message; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Check if an error indicates the gateway process has crashed. |