WK 8c2613713a
refactor: migrate eslint to v9 (#5267)
* 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
2025-06-01 13:51:30 -03:00

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;
}