( error: unknown, )
| 127 | } |
| 128 | |
| 129 | export const getCountryBlockFromFreeModeError = ( |
| 130 | error: unknown, |
| 131 | ): { |
| 132 | countryCode: string |
| 133 | countryBlockReason?: FreebuffCountryBlockReason |
| 134 | ipPrivacySignals?: FreebuffIpPrivacySignal[] |
| 135 | } | null => { |
| 136 | if (!isFreeModeUnavailableError(error)) return null |
| 137 | const errorDetails = getCliApiErrorDetails(error) |
| 138 | const countryCode = |
| 139 | typeof errorDetails.countryCode === 'string' && |
| 140 | errorDetails.countryCode.length > 0 |
| 141 | ? errorDetails.countryCode |
| 142 | : 'UNKNOWN' |
| 143 | |
| 144 | return { |
| 145 | countryCode, |
| 146 | countryBlockReason: |
| 147 | typeof errorDetails.countryBlockReason === 'string' |
| 148 | ? (errorDetails.countryBlockReason as FreebuffCountryBlockReason) |
| 149 | : undefined, |
| 150 | ipPrivacySignals: errorDetails.ipPrivacySignals as |
| 151 | | FreebuffIpPrivacySignal[] |
| 152 | | undefined, |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | export const getFreeModeUnavailableErrorMessage = ( |
| 157 | error: unknown, |
no test coverage detected