fix circular dependency caused by is-retryable-error, render-inline-error, and render-full-error
This commit is contained in:
parent
c2f6f54f50
commit
5f6578c8cd
6 changed files with 20 additions and 17 deletions
|
|
@ -10,23 +10,13 @@ import { MetaService } from '@/core/MetaService.js';
|
|||
import { MiMeta } from '@/models/Meta.js';
|
||||
import Logger from '@/logger.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { CaptchaError } from '@/misc/captcha-error.js';
|
||||
import { CaptchaError, captchaErrorCodes } from '@/misc/captcha-error.js';
|
||||
|
||||
export { CaptchaError } from '@/misc/captcha-error.js';
|
||||
|
||||
export const supportedCaptchaProviders = ['none', 'hcaptcha', 'mcaptcha', 'recaptcha', 'turnstile', 'fc', 'testcaptcha'] as const;
|
||||
export type CaptchaProvider = typeof supportedCaptchaProviders[number];
|
||||
|
||||
export const captchaErrorCodes = {
|
||||
invalidProvider: Symbol('invalidProvider'),
|
||||
invalidParameters: Symbol('invalidParameters'),
|
||||
noResponseProvided: Symbol('noResponseProvided'),
|
||||
requestFailed: Symbol('requestFailed'),
|
||||
verificationFailed: Symbol('verificationFailed'),
|
||||
unknown: Symbol('unknown'),
|
||||
} as const;
|
||||
export type CaptchaErrorCode = typeof captchaErrorCodes[keyof typeof captchaErrorCodes];
|
||||
|
||||
export type CaptchaSetting = {
|
||||
provider: CaptchaProvider;
|
||||
hcaptcha: {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,15 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { CaptchaErrorCode } from '@/core/CaptchaService.js';
|
||||
export const captchaErrorCodes = {
|
||||
invalidProvider: Symbol('invalidProvider'),
|
||||
invalidParameters: Symbol('invalidParameters'),
|
||||
noResponseProvided: Symbol('noResponseProvided'),
|
||||
requestFailed: Symbol('requestFailed'),
|
||||
verificationFailed: Symbol('verificationFailed'),
|
||||
unknown: Symbol('unknown'),
|
||||
} as const;
|
||||
export type CaptchaErrorCode = typeof captchaErrorCodes[keyof typeof captchaErrorCodes];
|
||||
|
||||
export class CaptchaError extends Error {
|
||||
public readonly code: CaptchaErrorCode;
|
||||
|
|
|
|||
6
packages/backend/src/misc/errors/ConflictError.ts
Normal file
6
packages/backend/src/misc/errors/ConflictError.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class ConflictError extends Error {}
|
||||
|
|
@ -7,9 +7,9 @@ import { AbortError, FetchError } from 'node-fetch';
|
|||
import { UnrecoverableError } from 'bullmq';
|
||||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { CaptchaError, captchaErrorCodes } from '@/core/CaptchaService.js';
|
||||
import { CaptchaError, captchaErrorCodes } from '@/misc/captcha-error.js';
|
||||
import { FastifyReplyError } from '@/misc/fastify-reply-error.js';
|
||||
import { ConflictError } from '@/server/SkRateLimiterService.js';
|
||||
import { ConflictError } from '@/misc/errors/ConflictError.js';
|
||||
|
||||
/**
|
||||
* Returns false if the provided value represents a "permanent" error that cannot be retried.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { AbortError, FetchError } from 'node-fetch';
|
|||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { CaptchaError, captchaErrorCodes } from '@/core/CaptchaService.js';
|
||||
import { CaptchaError, captchaErrorCodes } from '@/misc/captcha-error.js';
|
||||
|
||||
export function renderFullError(e?: unknown): unknown {
|
||||
if (e === undefined) return 'undefined';
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import Redis from 'ioredis';
|
|||
import type { TimeService } from '@/core/TimeService.js';
|
||||
import type { EnvService } from '@/core/EnvService.js';
|
||||
import { BucketRateLimit, LegacyRateLimit, LimitInfo, RateLimit, hasMinLimit, isLegacyRateLimit, Keyed, hasMaxLimit, disabledLimitInfo, MaxLegacyLimit, MinLegacyLimit } from '@/misc/rate-limit-utils.js';
|
||||
import { ConflictError } from '@/misc/errors/ConflictError.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { MemoryKVCache } from '@/misc/cache.js';
|
||||
import type { MiUser } from '@/models/_.js';
|
||||
|
|
@ -389,8 +390,6 @@ function createLimitKey(limit: ParsedLimit, actor: string, value: string): strin
|
|||
return `rl_${actor}_${limit.key}_${value}`;
|
||||
}
|
||||
|
||||
export class ConflictError extends Error {}
|
||||
|
||||
interface LimitCounter {
|
||||
timestamp: number;
|
||||
counter: number;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue