Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

568 B
Raw Blame
import { TRPCError } from "@trpc/server";

import { FlattenError } from "@homarr/common";
import { CustomWidgetDomainError } from "@homarr/custom-widgets/server";

class RequestLimitTransportError extends FlattenError {}

export function toTrpcError(error: unknown): never {
  if (error instanceof CustomWidgetDomainError) {
    const cause = error.retryAfterMs
      ? new RequestLimitTransportError(error.message, { retryAfterMs: error.retryAfterMs })
      : error;
    throw new TRPCError({ code: error.code, message: error.message, cause });
  }
  throw error;
}