MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getCountryBlockFromFreeModeError

Function getCountryBlockFromFreeModeError

cli/src/utils/error-handling.ts:129–154  ·  view source on GitHub ↗
(
  error: unknown,
)

Source from the content-addressed store, hash-verified

127}
128
129export 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
156export const getFreeModeUnavailableErrorMessage = (
157 error: unknown,

Callers 4

handleRunCompletionFunction · 0.90
handleRunErrorFunction · 0.90

Calls 2

getCliApiErrorDetailsFunction · 0.85

Tested by

no test coverage detected