fix: enhance error messages with context in various controllers and services

This commit is contained in:
Marco Pedone 2026-04-13 12:45:42 +02:00
parent e847aefe64
commit 4f21773cea
14 changed files with 151 additions and 121 deletions

View file

@ -82,7 +82,7 @@ export const inviteRouter = createTRPCRouter({
if (!user) { if (!user) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Utente non trovato", message: `Accept Invite: Utente non trovato con email: ${input.email}`,
}); });
} }
const invite = await verifyInviteToken(input.token); const invite = await verifyInviteToken(input.token);
@ -90,7 +90,7 @@ export const inviteRouter = createTRPCRouter({
if (!invite) { if (!invite) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Invito non valido o scaduto", message: `Accept Invite: Invito non valido o scaduto per email: ${input.email}`,
}); });
} }

View file

@ -49,7 +49,7 @@ export const getAnnunciListHandler = async (): Promise<
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore query getAllRaw: ${(e as Error).message}`, message: `Errore getAnnunciListHandler: ${(e as Error).message}`,
}); });
} }
}; };
@ -70,7 +70,7 @@ export const getCodici_AnnunciHandler = async (): Promise<string[]> => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore query getCodici: ${(e as Error).message}`, message: `Errore getCodici_AnnunciHandler: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -187,7 +187,7 @@ export const swapAuth = async ({
if (!user) { if (!user) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Utente non trovato", message: `Swap: Utente non trovato: ${userId}`,
}); });
} }
@ -219,10 +219,10 @@ export const swapAuth = async ({
req, req,
res, res,
}); });
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore interno", message: `Errore Swap Auth: ${(e as Error).message}`,
}); });
} }
}; };
@ -267,7 +267,7 @@ export const passwordChange = async ({
if (!dbUser) { if (!dbUser) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Utente non trovato", message: `Password Change: Utente non trovato: ${userId}`,
}); });
} }
const banned = await isBanned({ data: { email: dbUser.email }, db }); const banned = await isBanned({ data: { email: dbUser.email }, db });
@ -286,7 +286,7 @@ export const passwordChange = async ({
if (!isPasswordCorrect) { if (!isPasswordCorrect) {
throw new TRPCError({ throw new TRPCError({
code: "BAD_REQUEST", code: "BAD_REQUEST",
message: "Password errata", message: `Password Change: Password errata per utente: ${userId}`,
}); });
} }

View file

@ -4,7 +4,14 @@ import type { EtichetteIdEtichetta } from "~/schemas/public/Etichette";
import type { Querier } from "~/server/db"; import type { Querier } from "~/server/db";
export const getAllEtichette = async ({ db }: { db: Querier }) => { export const getAllEtichette = async ({ db }: { db: Querier }) => {
try {
return await db.selectFrom("etichette").selectAll().execute(); return await db.selectFrom("etichette").selectAll().execute();
} catch (e) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: `Errore recupero etichette: ${(e as Error).message}`,
});
}
}; };
export const addEtichetta = async ({ export const addEtichetta = async ({
db, db,
@ -22,10 +29,10 @@ export const addEtichetta = async ({
.returning("id_etichetta") .returning("id_etichetta")
.values({ color_hex, title }) .values({ color_hex, title })
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore aggiunta etichetta", message: `Errore aggiunta etichetta: ${(e as Error).message}`,
}); });
} }
}; };
@ -48,10 +55,10 @@ export const updateEtichetta = async ({
.set({ color_hex, title }) .set({ color_hex, title })
.where("id_etichetta", "=", etichettaid) .where("id_etichetta", "=", etichettaid)
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore aggiornamento etichetta", message: `Errore aggiornamento etichetta: ${(e as Error).message}`,
}); });
} }
}; };
@ -69,10 +76,10 @@ export const removeEtichetta = async ({
.where("id_etichetta", "=", etichettaid) .where("id_etichetta", "=", etichettaid)
.execute(); .execute();
return "ok"; return "ok";
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore rimozione etichetta", message: `Errore rimozione etichetta: ${(e as Error).message}`,
}); });
} }
}; };
@ -99,10 +106,10 @@ export const getChatEtichette = async ({
"etichette.color_hex", "etichette.color_hex",
]) ])
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore recupero etichette", message: `Errore recupero etichette: ${(e as Error).message}`,
}); });
} }
}; };
@ -123,10 +130,10 @@ export const addChatEtichette = async ({
.values({ chatid, etichettaid }) .values({ chatid, etichettaid })
.onConflict((oc) => oc.columns(["chatid", "etichettaid"]).doNothing()) .onConflict((oc) => oc.columns(["chatid", "etichettaid"]).doNothing())
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore aggiunta etichetta", message: `Errore aggiunta etichetta: ${(e as Error).message}`,
}); });
} }
}; };
@ -147,10 +154,10 @@ export const removeChatEtichette = async ({
.where("etichettaid", "=", etichettaid) .where("etichettaid", "=", etichettaid)
.execute(); .execute();
return "ok"; return "ok";
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore rimozione etichetta", message: `Errore rimozione etichetta: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -121,7 +121,7 @@ export const exportUserToFIC = async (userId: UsersId) => {
console.error("Error exporting user to FIC:", error); console.error("Error exporting user to FIC:", error);
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Failed to export user to Fatture In Cloud", message: `Failed to export user to Fatture In Cloud: ${(error as Error).message}`,
}); });
} }
}; };

View file

@ -588,7 +588,7 @@ export const getPacksPerServizio = async (
if (!servizio) { if (!servizio) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Servizio non trovato", message: `Servizio non trovato - servizioId: ${servizioId}`,
}); });
} }
return { return {
@ -608,7 +608,7 @@ export const previewSaldo = async (
if (!servizio) { if (!servizio) {
return { return {
success: false, success: false,
message: "Servizio non trovato", message: `Servizio non trovato - servizioId: ${servizioId}`,
}; };
} }
const saldo = await SaldoSolver({ const saldo = await SaldoSolver({

View file

@ -43,7 +43,7 @@ export const getDataPerAcquisto = async (servizioId: ServizioServizioId) => {
if (!servizio) { if (!servizio) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Servizio not found", message: `Servizio not found - servizioId: ${servizioId}`,
}); });
} }
@ -632,7 +632,7 @@ export const getServizioDataById = async (
if (!data) { if (!data) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Servizio not found", message: `Servizio not found - servizioId: ${servizioId}`,
}); });
} }
@ -640,7 +640,7 @@ export const getServizioDataById = async (
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: `Servizio annunci not found: ${(e as Error).message}`, message: `Servizio annunci not found - servizioId: ${servizioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -1150,7 +1150,15 @@ export type RichiesteData = Pick<
| "isOkConsulenza" | "isOkConsulenza"
| "interruzioneDays" | "interruzioneDays"
> & > &
Pick<Users, "username" | "note" | "telefono"> & { Pick<
Users,
| "nome"
| "username"
| "note"
| "telefono"
| "extra_telefono_numero"
| "extra_telefono_titolo"
> & {
annunci_servizio: ServizioAnnuncioData[]; annunci_servizio: ServizioAnnuncioData[];
ordini_servizio: Pick< ordini_servizio: Pick<
Ordini, Ordini,
@ -1182,7 +1190,14 @@ export const getRichieste = async (): Promise<RichiesteData[]> => {
"servizio.isOkConsulenza", "servizio.isOkConsulenza",
"servizio.interruzioneDays", "servizio.interruzioneDays",
]) ])
.select(["users.username", "users.note", "users.telefono"]) .select([
"users.nome",
"users.username",
"users.note",
"users.telefono",
"users.extra_telefono_numero",
"users.extra_telefono_titolo",
])
.select((eb) => [ .select((eb) => [
jsonArrayFrom( jsonArrayFrom(
eb eb

View file

@ -22,10 +22,10 @@ export const editAccountHandler = async ({
.execute(); .execute();
return "success"; return "success";
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "errore modifica utente", message: `errore modifica utente - id: ${id}: ${(e as Error).message}`,
}); });
} }
}; };
@ -42,7 +42,7 @@ export const editAnagraficaHandler = async ({
if (!userId) { if (!userId) {
throw new TRPCError({ throw new TRPCError({
code: "BAD_REQUEST", code: "BAD_REQUEST",
message: "Errore interno, utente non trovato", message: `Errore interno, utente non trovato - userId: ${userId}`,
}); });
} }
@ -62,7 +62,7 @@ export const editAnagraficaHandler = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore updateAnagrafica: ${(e as Error).message}`, message: `Errore updateAnagrafica - userId: ${userId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -71,10 +71,10 @@ export const deleteUserHandler = async (id: UsersId) => {
try { try {
await db.deleteFrom("users").where("id", "=", id).execute(); await db.deleteFrom("users").where("id", "=", id).execute();
return { success: true }; return { success: true };
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "errore cancellazione utente", message: `errore cancellazione utente - id: ${id}: ${(e as Error).message}`,
}); });
} }
}; };
@ -112,10 +112,10 @@ export const getUserHandler = async ({
return null; return null;
} }
return user; return user;
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "errore get utente", message: `errore get utente - id: ${id}: ${(e as Error).message}`,
}); });
} }
}; };
@ -131,6 +131,7 @@ export const getActiveUserWithoutChatHandler = async ({
}: { }: {
db: Querier; db: Querier;
}) => { }) => {
try {
const users = await db const users = await db
.selectFrom("users") .selectFrom("users")
.fullJoin("chats", "chats.user_ref", "users.id") .fullJoin("chats", "chats.user_ref", "users.id")
@ -142,11 +143,18 @@ export const getActiveUserWithoutChatHandler = async ({
return users.filter((user): user is NonNullableUser => { return users.filter((user): user is NonNullableUser => {
return user.id !== null && user.username !== null; return user.id !== null && user.username !== null;
}); });
} catch (e) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: `errore getActiveUserWithoutChatHandler: ${(e as Error).message}`,
});
}
}; };
export type UserWChatInfo = Pick< export type UserWChatInfo = Pick<
Users, Users,
| "id" | "id"
| "nome"
| "username" | "username"
| "email" | "email"
| "telefono" | "telefono"

View file

@ -25,10 +25,10 @@ export const genPasswordResetToken = async ({ id }: { id: UsersId }) => {
.where("id", "=", id) .where("id", "=", id)
.execute(); .execute();
return newToken; return newToken;
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore interno", message: `genPasswordResetToken: Errore interno: ${(e as Error).message}`,
}); });
} }
}; };
@ -49,7 +49,7 @@ export const isTokenValid = async ({ token }: { token: string }) => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore interno: ${(e as Error).message}`, message: `isTokenValid: Errore interno: ${(e as Error).message}`,
}); });
} }
}; };
@ -91,7 +91,7 @@ export const resetPasswordFromTokenHandler = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore interno: ${(e as Error).message}`, message: `Password Reset: Errore interno: ${(e as Error).message}`,
}); });
} }
}; };
@ -101,7 +101,7 @@ export const pwResetSendLinkHandler = async ({ email }: { email: string }) => {
if (!user) { if (!user) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: "Utente non trovato", message: `Password Reset: Utente non trovato con email: ${email}`,
}); });
} }
@ -143,10 +143,10 @@ export const passwordOverrideHandler = async ({
return { return {
status: "success", status: "success",
}; };
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore interno", message: `Password Override: Errore interno: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -20,10 +20,10 @@ export const getBanner = async ({
query = query.where("banners.show_public", "=", true); query = query.where("banners.show_public", "=", true);
} }
return await query.execute(); return await query.execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore nel recupero dei dati", message: `Errore nel recupero dei dati: ${(e as Error).message}`,
}); });
} }
}; };
@ -31,10 +31,10 @@ export const getBanner = async ({
export const getAllBanners = async ({ db }: { db: Querier }) => { export const getAllBanners = async ({ db }: { db: Querier }) => {
try { try {
return await db.selectFrom("banners").selectAll().execute(); return await db.selectFrom("banners").selectAll().execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore nel recupero dei dati", message: `Errore nel recupero dei dati: ${(e as Error).message}`,
}); });
} }
}; };
@ -55,10 +55,10 @@ export const addBanner = async ({
}) })
.returning("banners.idbanner") .returning("banners.idbanner")
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore aggiunta banner", message: `Errore aggiunta banner: ${(e as Error).message}`,
}); });
} }
}; };
@ -80,10 +80,10 @@ export const updateBanner = async ({
.where("banners.idbanner", "=", input.idbanner) .where("banners.idbanner", "=", input.idbanner)
.returning("banners.idbanner") .returning("banners.idbanner")
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore aggiornamento banner", message: `Errore aggiornamento banner: ${(e as Error).message}`,
}); });
} }
}; };
@ -101,10 +101,10 @@ export const deleteBanner = async ({
.where("banners.idbanner", "=", input.idbanner) .where("banners.idbanner", "=", input.idbanner)
.execute(); .execute();
return "ok"; return "ok";
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: "Errore eliminazione banner", message: `Errore eliminazione banner: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -27,10 +27,10 @@ export const editMessage = async ({
.where("messages.messageid", "=", messageId) .where("messages.messageid", "=", messageId)
.returning("messageid") .returning("messageid")
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "BAD_REQUEST", code: "BAD_REQUEST",
message: "Error while editing message", message: `Error while editing message: ${(e as Error).message}`,
}); });
} }
}; };
@ -55,10 +55,10 @@ export const setReadMessage = async ({
.where("messages.chatid", "=", chatId) .where("messages.chatid", "=", chatId)
.returning("messages.chatid") .returning("messages.chatid")
.execute(); .execute();
} catch { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "BAD_REQUEST", code: "BAD_REQUEST",
message: "Error while setting read status", message: `Error while setting read status: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -65,7 +65,7 @@ export const getServizioById = async (servizioId: ServizioServizioId) => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: `Servizio not found: ${(e as Error).message}`, message: `Servizio not found - servizioId: ${servizioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -90,7 +90,7 @@ export const updateServizio = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Error updating servizio: ${(e as Error).message}`, message: `Error updating servizio - servizioId: ${servizioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -105,7 +105,7 @@ export const deleteServizio = async (servizioId: ServizioServizioId) => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Error deleting servizio: ${(e as Error).message}`, message: `Error deleting servizio - servizioId: ${servizioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -134,7 +134,7 @@ export const getServizioAnnuncio = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "NOT_FOUND", code: "NOT_FOUND",
message: `Servizio not found: ${(e as Error).message}`, message: `Servizio not found - servizioId: ${servizioId}, annunciId: ${annuncioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -160,7 +160,7 @@ export const updateServizioAnnuncio = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Error updating servizio from annuncio: ${(e as Error).message}`, message: `Error updating servizio from annuncio - servizioId: ${servizioId}, annunciId: ${annuncioId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -179,7 +179,7 @@ export const deleteServizioAnnuncio = async (
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Error deleting servizio from annuncio: ${(e as Error).message}`, message: `Error deleting servizio from annuncio - servizioId: ${servizioId}, annunciId: ${annuncioId}: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -28,7 +28,7 @@ export const getStringheFiltered = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore nel recupero delle stringhe: ${(e as Error).message}`, message: `Errore nel recupero delle stringhe - contains: ${contains}: ${(e as Error).message}`,
}); });
} }
}; };
@ -49,7 +49,7 @@ export const getStringa = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore recupero stringa: ${(e as Error).message}`, message: `Errore recupero stringa - stringaId: ${stringaId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -72,7 +72,7 @@ export const newStringa = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore aggiunta della stringa: ${(e as Error).message}`, message: `Errore aggiunta della stringa - stringaId: ${stringaId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -96,7 +96,7 @@ export const updateStringhe = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore aggiornamento stringa: ${(e as Error).message}`, message: `Errore aggiornamento stringa - stringaId: ${stringaId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -117,7 +117,7 @@ export const deleteStringa = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore cancellazione stringa: ${(e as Error).message}`, message: `Errore cancellazione stringa - stringaId: ${stringaId}: ${(e as Error).message}`,
}); });
} }
}; };

View file

@ -14,7 +14,7 @@ export const findUser_byId = async ({ id }: { id: string }) => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore findUser_byId: ${(e as Error).message}`, message: `Errore findUser_byId - id: ${id}: ${(e as Error).message}`,
}); });
} }
}; };
@ -28,7 +28,7 @@ export const findUser_byEmail = async ({ email }: { email: string }) => {
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore findUser_byEmail: ${(e as Error).message}`, message: `Errore findUser_byEmail - email: ${email}: ${(e as Error).message}`,
}); });
} }
}; };
@ -54,7 +54,7 @@ export const findUser_byId_MINI = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `errore findUser_byId_MINI: ${(e as Error).message}`, message: `errore findUser_byId_MINI - userId: ${userId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -77,7 +77,7 @@ export const getUser = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `errore getUtente: ${(e as Error).message}`, message: `errore getUser - userId: ${userId}: ${(e as Error).message}`,
}); });
} }
}; };
@ -103,7 +103,7 @@ export const addUser = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore addUser: ${(e as Error).message}`, message: `Errore addUser - email: ${data.email}: ${(e as Error).message}`,
}); });
} }
}; };
@ -170,7 +170,7 @@ export const getClientProfilo = async ({
} catch (e) { } catch (e) {
throw new TRPCError({ throw new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
message: `Errore interno: ${(e as Error).message}`, message: `Errore interno - userId: ${userId}: ${(e as Error).message}`,
}); });
} }
}; };