Turn on custom-error-definition and name the custom errors
This commit is contained in:
@@ -260,9 +260,6 @@ const rules: DummyRuleMap = {
|
|||||||
// PENDING USER: union members are values in profiles.json, the Gitea API,
|
// PENDING USER: union members are values in profiles.json, the Gitea API,
|
||||||
// and posted comments; renaming them changes behavior.
|
// and posted comments; renaming them changes behavior.
|
||||||
"explicit-types/upper-snake-string-unions": "off",
|
"explicit-types/upper-snake-string-unions": "off",
|
||||||
// PENDING USER: a fitting `name` needs a constructor and changes logged
|
|
||||||
// error names.
|
|
||||||
"unicorn/custom-error-definition": "off",
|
|
||||||
// Off, too much churn:
|
// Off, too much churn:
|
||||||
// Literal numbers read better than a constant per use.
|
// Literal numbers read better than a constant per use.
|
||||||
"no-magic-numbers": "off",
|
"no-magic-numbers": "off",
|
||||||
|
|||||||
+6
-1
@@ -36,7 +36,12 @@ const failureComment = (failures: ProfileFailure[]): string =>
|
|||||||
// The `fetch` subset the reviewer posts through, which tests replace.
|
// The `fetch` subset the reviewer posts through, which tests replace.
|
||||||
export type Fetcher = (url: string, init: RequestInit) => Promise<Response>;
|
export type Fetcher = (url: string, init: RequestInit) => Promise<Response>;
|
||||||
|
|
||||||
class GiteaRequestError extends Error {}
|
class GiteaRequestError extends Error {
|
||||||
|
constructor(message: string, options?: ErrorOptions) {
|
||||||
|
super(message, options);
|
||||||
|
this.name = "GiteaRequestError";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function parseAnchors(text: string, sourcePath: string): Anchor[] {
|
function parseAnchors(text: string, sourcePath: string): Anchor[] {
|
||||||
const entries: unknown = JSON.parse(text);
|
const entries: unknown = JSON.parse(text);
|
||||||
|
|||||||
@@ -29,7 +29,12 @@ interface ProfileHome {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Raised once an agent's credentials are rejected and any re-login is spent.
|
// Raised once an agent's credentials are rejected and any re-login is spent.
|
||||||
export class AgentAuthError extends Error {}
|
export class AgentAuthError extends Error {
|
||||||
|
constructor(message: string, options?: ErrorOptions) {
|
||||||
|
super(message, options);
|
||||||
|
this.name = "AgentAuthError";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isUsageExhausted(error: unknown): boolean {
|
function isUsageExhausted(error: unknown): boolean {
|
||||||
return /(?:usage|rate) limit|hit your (?:weekly )?limit|insufficient_quota|exceeded your current quota|too many requests|(?:api error|http error|http|status(?: code)?)[ :]+4(?:02|29)\b/iu.test(
|
return /(?:usage|rate) limit|hit your (?:weekly )?limit|insufficient_quota|exceeded your current quota|too many requests|(?:api error|http error|http|status(?: code)?)[ :]+4(?:02|29)\b/iu.test(
|
||||||
|
|||||||
Reference in New Issue
Block a user