add mana core

This commit is contained in:
Wuesteon 2025-11-25 18:56:35 +01:00
parent ce71db2fc0
commit 754e87ebc0
112 changed files with 34765 additions and 548 deletions

View file

@ -0,0 +1,31 @@
import { ErrorCode } from '../types/error-codes';
import { AppError } from './app-error';
/**
* Error for rate limiting.
* HTTP Status: 429 Too Many Requests
*
* @example
* ```typescript
* // Basic rate limit error
* return err(new RateLimitError());
*
* // With retry-after information
* return err(new RateLimitError('Too many requests', 60));
* // Client should wait 60 seconds before retrying
* ```
*/
export class RateLimitError extends AppError {
/** Seconds to wait before retrying (if known) */
readonly retryAfter?: number;
constructor(message = 'Rate limit exceeded', retryAfter?: number) {
super({
code: ErrorCode.RATE_LIMIT_EXCEEDED,
message,
context: retryAfter ? { retryAfter } : {},
});
this.name = 'RateLimitError';
this.retryAfter = retryAfter;
}
}