export class AssertionError extends Error {
  override name = 'AssertionError';
  constructor(message: string) {
    super(message);
  }
}

/** Asserts that the provided condition is truthy */
export function assert(condition: unknown, message = ''): asserts condition {
  if (!condition) throw new AssertionError(message);
}

/** Asserts that the provided value is a non-empty string */
export function assertString(value: unknown, message?: string): asserts value is string {
  assert(typeof value === 'string' && value.length > 0, message);
}
