export class TypeOrmPersistenceSchemaError extends Error {
  public readonly entityName: string;
  public readonly fieldName: string;
  public readonly reason: string;
  public readonly message: string;

  constructor(params: {
    entityName: string;
    fieldName: string;
    reason: string;
    message?: string;
  }) {
    const errorMessage = params.message || `Schema validation failed for ${params.entityName}.${params.fieldName}: ${params.reason}`;
    super(errorMessage);
    this.name = 'TypeOrmPersistenceSchemaError';
    this.entityName = params.entityName;
    this.fieldName = params.fieldName;
    this.reason = params.reason;
    this.message = errorMessage;
  }
}