import { IServerError, ServerError } from "../../domain/errors";

export interface IUseCaseError extends IServerError {}

export type UseCaseErrorDetails = {
  path?: string;
} & Record<string, any>;

export class UseCaseError extends ServerError implements IUseCaseError {
  public static readonly INVALID_REQUEST_PARAM = "INVALID_REQUEST_PARAM";
  public static readonly INVALID_INPUT_DATA = "INVALID_INPUT_DATA";
  public static readonly UNEXCEPTED_ERROR = "UNEXCEPTED_ERROR";
  public static readonly REPOSITORY_ERROR = "REPOSITORY_ERROR";
  public static readonly NOT_FOUND_ERROR = "NOT_FOUND_ERROR";
  public static readonly RESOURCE_ALREADY_EXITS = "RESOURCE_ALREADY_EXITS";

  public static create(
    code: string,
    message: string,
    details?: UseCaseErrorDetails,
  ): UseCaseError {
    return new UseCaseError(code, message, details);
  }
}
