import { TRPCError } from '../TRPCError' ; export function getMessageFromUnkownError ( err , fallback ) { if ( typeof err === 'string' ) { return err ; } if ( err instanceof Error && typeof err . message === 'string' ) { return err . message ; } return fallback ; } export function getErrorFromUnknown ( cause ) { if ( cause instanceof Error && cause . name === 'TRPCError' ) { return cause as TRPCError ; } const err = new TRPCError ( { code : 'INTERNAL_SERVER_ERROR' , cause } ) ; if ( cause instanceof Error ) { err . stack = cause . stack ; } return err ; }