<?php
namespace nulib\schema;

use Exception;

class SchemaException extends Exception {
  static final function invalid_schema(?string $message=null): self {
    $invalid_schema = "invalid schema";
    if ($message !== null) $invalid_schema .= ": $message";
    return new static($invalid_schema);
  }

  static final function invalid_kind(string $kind, $value, ?string $message=null): self {
    $invalid_kind = var_export($value, true).": invalid $kind";
    if ($message !== null) $invalid_kind .= ": $message";
    return new static($invalid_kind);
  }

  static final function invalid_type($value, ?string $message=null): self {
    return self::invalid_kind("type", $value, $message);
  }
}
