export interface TypeOrmPersistenceSchemaErrorProps {
  entityName: string;
  fieldName: string;
  reason: string;
  message?: string;
}

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

  constructor(props: TypeOrmPersistenceSchemaErrorProps) {
    const message = props.message || `Invalid schema for ${props.entityName}.${props.fieldName}: ${props.reason}`;
    super(message);
    this.name = 'TypeOrmPersistenceSchemaError';
    this.entityName = props.entityName;
    this.fieldName = props.fieldName;
    this.reason = props.reason;
  }
}