MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / getClaimGatewayErrorMessage

Function getClaimGatewayErrorMessage

pkg/webui/lib/errors/utils.js:601–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599 * @returns {object|undefined} - The corresponding error message, or undefined if no match.
600 */
601export 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}

Callers 1

index.jsFile · 0.90

Calls 1

getBackendErrorRootCauseFunction · 0.85

Tested by

no test coverage detected