import { z } from "zod";

import { ExceptionCode } from "../exception-code";
import type { ExceptionResult } from "../exception-result";

export class ValidationExceptionHandler {
  static canHandle(error: unknown): error is z.ZodError | SyntaxError {
    return error instanceof z.ZodError || error instanceof SyntaxError;
  }

  static handle(error?: z.ZodError | SyntaxError): ExceptionResult {
    void error;
    return {
      code: ExceptionCode.validation,
      message: "Data format changed unexpectedly. Please try again.",
    };
  }
}
