mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* refactor: migrate eslint to v9 * chore: lint * chore: update eslint command * chore: fix lint warnings * chore: separate lint and lint:fix * chore: exclude contentlayer generated code * fix(scripts): add missing await
25 lines
520 B
TypeScript
25 lines
520 B
TypeScript
export interface GithubError extends Error {
|
|
url: string;
|
|
status: number;
|
|
headers: Response["headers"];
|
|
}
|
|
|
|
function getErrorText(res: Response) {
|
|
try {
|
|
return res.text();
|
|
} catch {
|
|
return res.statusText;
|
|
}
|
|
}
|
|
|
|
export async function getError(msg: string, res: Response) {
|
|
const errorText = await getErrorText(res);
|
|
const error = new Error(`${msg} (${res.status}): ${errorText}`) as GithubError;
|
|
|
|
error.url = res.url;
|
|
error.status = res.status;
|
|
error.headers = res.headers;
|
|
|
|
return error;
|
|
}
|