/**
 * `throw new ApiError(404, "Not found")` inside an endpoint → the client's promise rejects with the
 * same status + message. Any other throw is a 500 (message hidden, logged to the server console).
 */
export class ApiError extends Error {
  readonly status: number
  constructor(status: number, message = "") {
    super(message)
    this.name = "ApiError"
    this.status = status
  }
}
