import { type Maybe } from '../value/maybe.type'; import { type ReadableDataError, type StringErrorCode, type CodedError } from './error'; /** * The expected error object returned from the server. */ export type ServerErrorResponseData = object; /** * Human-readable server error with additional data and a status code. */ export interface ServerError extends ReadableDataError { readonly status: number; } /** * Type guard that checks if the input is a ServerError (has both status and code properties). * * @param input - The value to check * @returns True if the input is a ServerError */ export declare function isServerError(input: unknown): input is ServerError; /** * Union type for either a plain error message string or a partial server error object. */ export type ErrorMessageOrPartialServerError = string | Partial>; /** * Normalizes a string or partial error into a Partial ServerError object. * If the input is a string, it becomes the message property. * * @param message - a plain error message string that becomes the `message` property of the returned object * @param messageOrError - A string message or partial server error object * @returns A partial ServerError object */ export declare function partialServerError(message: string): Partial>; export declare function partialServerError(serverError: Partial>): Partial>; export declare function partialServerError(messageOrError: Maybe>): Partial>; /** * Configuration for creating a ServerError, combining ServerError and optional CodedError properties. */ export interface ServerErrorMakeConfig extends ServerError, Partial { } /** * Creates a ServerError from the given configuration. * * @param config - The server error configuration * @returns A ServerError object */ export declare function serverError(config: ServerErrorMakeConfig): ServerError; /** * Base server-error class. */ export declare class ServerErrorResponse implements ServerError { readonly status: number; readonly code?: StringErrorCode; readonly message?: Maybe; readonly data?: T; constructor({ code, status, data, message }: ServerError); } /** * Server error response with a 401 Unauthorized status. */ export declare class UnauthorizedServerErrorResponse extends ServerErrorResponse { constructor({ code, data, message }: Partial); }