export type TypeOrmSocialSchemaErrorReason =
  | 'missing'
  | 'not_string'
  | 'empty_string'
  | 'not_number'
  | 'not_integer'
  | 'not_boolean'
  | 'not_date'
  | 'invalid_date'
  | 'invalid_enum_value'
  | 'invalid_shape';

export class TypeOrmSocialSchemaError extends Error {
  readonly entityName: string;
  readonly fieldName: string;
  readonly reason: TypeOrmSocialSchemaErrorReason | (string & {});

  constructor(params: {
    entityName: string;
    fieldName: string;
    reason: TypeOrmSocialSchemaError['reason'];
    message?: string;
  }) {
    const { entityName, fieldName, reason, message } = params;
    super(message);

    this.name = 'TypeOrmSocialSchemaError';
    this.entityName = entityName;
    this.fieldName = fieldName;
    this.reason = reason;
  }
}