| 599 | * @returns {object|undefined} - The corresponding error message, or undefined if no match. |
| 600 | */ |
| 601 | export const getClaimGatewayErrorMessage = error => { |
| 602 | const m = defineMessages({ |
| 603 | notFound: "Gateway doesn't exist. Please confirm that the gateway EUI is correct.", |
| 604 | subscriptionNotActive: |
| 605 | 'There is no gateway subscription attached or active. Please get a <link>Gateway Subscription</link> or activate your subscription following the steps in the documentation. If this gateway is part of a fleet, you should use a Fleet Owner Token during the registration process.', |
| 606 | permissionDenied: 'The owner token is invalid.', |
| 607 | }) |
| 608 | |
| 609 | const rootCause = getBackendErrorRootCause(error) |
| 610 | const errorCode = rootCause?.code |
| 611 | const backendErrorMessage = rootCause?.message_format |
| 612 | switch (errorCode) { |
| 613 | case 5: // NOT_FOUND |
| 614 | return m.notFound |
| 615 | case 9: // FAILED_PRECONDITION |
| 616 | if (backendErrorMessage.includes('gateway subscription not attached and active')) { |
| 617 | return m.subscriptionNotActive |
| 618 | } |
| 619 | return undefined |
| 620 | case 7: // PERMISSION_DENIED |
| 621 | return m.permissionDenied |
| 622 | default: |
| 623 | return undefined |
| 624 | } |
| 625 | } |
no test coverage detected