File size: 911 Bytes
d739b1b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** ๊ณต๊ธ์ ์ค๋ฅ์ ์๋ฌธ/URL/์๊ฒฉ ์์ด OpenCode ๊ตฌ์กฐํ HTTP ์ํ๋ง ์ ๋ฌํ๋ค.
* ์ค๋ช
๋ฌธ์: docs/specs/opencode-google-execution.md (v1.0.0)
*/
function providerHttpError(error) {
const status = error?.name === 'APIError' ? error.data?.statusCode : undefined;
if (!Number.isInteger(status) || status < 400 || status > 599) return null;
const kind = status === 401 ? 'authentication' : status === 403 ? 'permission' :
status === 404 ? 'not_found' : status === 429 ? 'rate_limit' : status >= 500 ? 'upstream' : 'rejected';
// ๋ชจ๋ธ ์์ฒญ ์ ์ ์คํจํ๋์ง, ์ด์ ๋๊ตฌ ํจ๊ณผ๊ฐ ์์๋์ง ์ ์ ์์ด ์์
์ ์ฒด๋ฅผ ์ฌ์ ์กํ์ง ์๋๋ค.
return Object.assign(new Error('CLI provider request failed (HTTP ' + status + ')'), {
code: 'CLI_PROVIDER_HTTP_ERROR', httpStatus: status, kind, retryable: false
});
}
module.exports = { providerHttpError };
|