mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
fix: improve error log coverage (#1070)
## Description Increase coverage of error logging in TRPC routes.
This commit is contained in:
@ -29,6 +29,8 @@ export const adminRouter = router({
|
|||||||
try {
|
try {
|
||||||
return await findDocuments({ term, page, perPage });
|
return await findDocuments({ term, page, perPage });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to retrieve the documents. Please try again.',
|
message: 'We were unable to retrieve the documents. Please try again.',
|
||||||
@ -44,6 +46,8 @@ export const adminRouter = router({
|
|||||||
try {
|
try {
|
||||||
return await updateUser({ id, name, email, roles });
|
return await updateUser({ id, name, email, roles });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to retrieve the specified account. Please try again.',
|
message: 'We were unable to retrieve the specified account. Please try again.',
|
||||||
@ -59,6 +63,8 @@ export const adminRouter = router({
|
|||||||
try {
|
try {
|
||||||
return await updateRecipient({ id, name, email });
|
return await updateRecipient({ id, name, email });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to update the recipient provided.',
|
message: 'We were unable to update the recipient provided.',
|
||||||
@ -79,6 +85,8 @@ export const adminRouter = router({
|
|||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to update the site setting provided.',
|
message: 'We were unable to update the site setting provided.',
|
||||||
@ -95,6 +103,7 @@ export const adminRouter = router({
|
|||||||
return await sealDocument({ documentId: id, isResealing: true });
|
return await sealDocument({ documentId: id, isResealing: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('resealDocument error', err);
|
console.log('resealDocument error', err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to reseal the document provided.',
|
message: 'We were unable to reseal the document provided.',
|
||||||
|
|||||||
@ -16,7 +16,9 @@ export const apiTokenRouter = router({
|
|||||||
getTokens: authenticatedProcedure.query(async ({ ctx }) => {
|
getTokens: authenticatedProcedure.query(async ({ ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await getUserTokens({ userId: ctx.user.id });
|
return await getUserTokens({ userId: ctx.user.id });
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to find your API tokens. Please try again.',
|
message: 'We were unable to find your API tokens. Please try again.',
|
||||||
@ -34,7 +36,9 @@ export const apiTokenRouter = router({
|
|||||||
id,
|
id,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to find this API token. Please try again.',
|
message: 'We were unable to find this API token. Please try again.',
|
||||||
@ -54,7 +58,9 @@ export const apiTokenRouter = router({
|
|||||||
tokenName,
|
tokenName,
|
||||||
expiresIn: expirationDate,
|
expiresIn: expirationDate,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to create an API token. Please try again.',
|
message: 'We were unable to create an API token. Please try again.',
|
||||||
@ -73,7 +79,9 @@ export const apiTokenRouter = router({
|
|||||||
teamId,
|
teamId,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to delete this API Token. Please try again.',
|
message: 'We were unable to delete this API Token. Please try again.',
|
||||||
|
|||||||
@ -115,6 +115,8 @@ export const documentRouter = router({
|
|||||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
if (err instanceof TRPCError) {
|
if (err instanceof TRPCError) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
@ -222,13 +224,19 @@ export const documentRouter = router({
|
|||||||
|
|
||||||
const userId = ctx.user.id;
|
const userId = ctx.user.id;
|
||||||
|
|
||||||
return await updateTitle({
|
try {
|
||||||
title,
|
return await updateTitle({
|
||||||
userId,
|
title,
|
||||||
teamId,
|
userId,
|
||||||
documentId,
|
teamId,
|
||||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
documentId,
|
||||||
});
|
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
setPasswordForDocument: authenticatedProcedure
|
setPasswordForDocument: authenticatedProcedure
|
||||||
@ -347,7 +355,9 @@ export const documentRouter = router({
|
|||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
return documents;
|
return documents;
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We are unable to search for documents. Please try again later.',
|
message: 'We are unable to search for documents. Please try again later.',
|
||||||
|
|||||||
@ -52,20 +52,26 @@ export const fieldRouter = router({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const { templateId, fields } = input;
|
const { templateId, fields } = input;
|
||||||
|
|
||||||
await setFieldsForTemplate({
|
try {
|
||||||
userId: ctx.user.id,
|
await setFieldsForTemplate({
|
||||||
templateId,
|
userId: ctx.user.id,
|
||||||
fields: fields.map((field) => ({
|
templateId,
|
||||||
id: field.nativeId,
|
fields: fields.map((field) => ({
|
||||||
signerEmail: field.signerEmail,
|
id: field.nativeId,
|
||||||
type: field.type,
|
signerEmail: field.signerEmail,
|
||||||
pageNumber: field.pageNumber,
|
type: field.type,
|
||||||
pageX: field.pageX,
|
pageNumber: field.pageNumber,
|
||||||
pageY: field.pageY,
|
pageX: field.pageX,
|
||||||
pageWidth: field.pageWidth,
|
pageY: field.pageY,
|
||||||
pageHeight: field.pageHeight,
|
pageWidth: field.pageWidth,
|
||||||
})),
|
pageHeight: field.pageHeight,
|
||||||
});
|
})),
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
signFieldWithToken: procedure
|
signFieldWithToken: procedure
|
||||||
|
|||||||
@ -37,6 +37,8 @@ export const profileRouter = router({
|
|||||||
...input,
|
...input,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to find user security audit logs. Please try again.',
|
message: 'We were unable to find user security audit logs. Please try again.',
|
||||||
@ -50,6 +52,8 @@ export const profileRouter = router({
|
|||||||
|
|
||||||
return await getUserById({ id });
|
return await getUserById({ id });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to retrieve the specified account. Please try again.',
|
message: 'We were unable to retrieve the specified account. Please try again.',
|
||||||
@ -108,6 +112,8 @@ export const profileRouter = router({
|
|||||||
|
|
||||||
return { success: true, url: user.url };
|
return { success: true, url: user.url };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
const error = AppError.parseError(err);
|
const error = AppError.parseError(err);
|
||||||
|
|
||||||
if (error.code !== AppErrorCode.UNKNOWN_ERROR) {
|
if (error.code !== AppErrorCode.UNKNOWN_ERROR) {
|
||||||
@ -135,6 +141,8 @@ export const profileRouter = router({
|
|||||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
let message =
|
let message =
|
||||||
'We were unable to update your profile. Please review the information you provided and try again.';
|
'We were unable to update your profile. Please review the information you provided and try again.';
|
||||||
|
|
||||||
@ -171,6 +179,8 @@ export const profileRouter = router({
|
|||||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
let message = 'We were unable to reset your password. Please try again.';
|
let message = 'We were unable to reset your password. Please try again.';
|
||||||
|
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
@ -192,6 +202,8 @@ export const profileRouter = router({
|
|||||||
|
|
||||||
return await sendConfirmationToken({ email });
|
return await sendConfirmationToken({ email });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
let message = 'We were unable to send a confirmation email. Please try again.';
|
let message = 'We were unable to send a confirmation email. Please try again.';
|
||||||
|
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
@ -211,6 +223,8 @@ export const profileRouter = router({
|
|||||||
id: ctx.user.id,
|
id: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
let message = 'We were unable to delete your account. Please try again.';
|
let message = 'We were unable to delete your account. Please try again.';
|
||||||
|
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
|
|||||||
@ -29,151 +29,157 @@ export const singleplayerRouter = router({
|
|||||||
createSinglePlayerDocument: procedure
|
createSinglePlayerDocument: procedure
|
||||||
.input(ZCreateSinglePlayerDocumentMutationSchema)
|
.input(ZCreateSinglePlayerDocumentMutationSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
const { signer, fields, documentData, documentName } = input;
|
try {
|
||||||
|
const { signer, fields, documentData, documentName } = input;
|
||||||
|
|
||||||
const document = await getFile({
|
const document = await getFile({
|
||||||
data: documentData.data,
|
data: documentData.data,
|
||||||
type: documentData.type,
|
type: documentData.type,
|
||||||
});
|
|
||||||
|
|
||||||
const doc = await PDFDocument.load(document);
|
|
||||||
|
|
||||||
const createdAt = new Date();
|
|
||||||
|
|
||||||
const isBase64 = signer.signature.startsWith('data:image/png;base64,');
|
|
||||||
const signatureImageAsBase64 = isBase64 ? signer.signature : null;
|
|
||||||
const typedSignature = !isBase64 ? signer.signature : null;
|
|
||||||
|
|
||||||
// Update the document with the fields inserted.
|
|
||||||
for (const field of fields) {
|
|
||||||
const isSignatureField = field.type === FieldType.SIGNATURE;
|
|
||||||
|
|
||||||
await insertFieldInPDF(doc, {
|
|
||||||
...mapField(field, signer),
|
|
||||||
Signature: isSignatureField
|
|
||||||
? {
|
|
||||||
created: createdAt,
|
|
||||||
signatureImageAsBase64,
|
|
||||||
typedSignature,
|
|
||||||
// Dummy data.
|
|
||||||
id: -1,
|
|
||||||
recipientId: -1,
|
|
||||||
fieldId: -1,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
// Dummy data.
|
|
||||||
id: -1,
|
|
||||||
secondaryId: '-1',
|
|
||||||
documentId: -1,
|
|
||||||
templateId: null,
|
|
||||||
recipientId: -1,
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const unsignedPdfBytes = await doc.save();
|
const doc = await PDFDocument.load(document);
|
||||||
|
|
||||||
const signedPdfBuffer = await signPdf({ pdf: Buffer.from(unsignedPdfBytes) });
|
const createdAt = new Date();
|
||||||
|
|
||||||
const { token } = await prisma.$transaction(
|
const isBase64 = signer.signature.startsWith('data:image/png;base64,');
|
||||||
async (tx) => {
|
const signatureImageAsBase64 = isBase64 ? signer.signature : null;
|
||||||
const token = alphaid();
|
const typedSignature = !isBase64 ? signer.signature : null;
|
||||||
|
|
||||||
// Fetch service user who will be the owner of the document.
|
// Update the document with the fields inserted.
|
||||||
const serviceUser = await tx.user.findFirstOrThrow({
|
for (const field of fields) {
|
||||||
where: {
|
const isSignatureField = field.type === FieldType.SIGNATURE;
|
||||||
email: SERVICE_USER_EMAIL,
|
|
||||||
},
|
await insertFieldInPDF(doc, {
|
||||||
|
...mapField(field, signer),
|
||||||
|
Signature: isSignatureField
|
||||||
|
? {
|
||||||
|
created: createdAt,
|
||||||
|
signatureImageAsBase64,
|
||||||
|
typedSignature,
|
||||||
|
// Dummy data.
|
||||||
|
id: -1,
|
||||||
|
recipientId: -1,
|
||||||
|
fieldId: -1,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
// Dummy data.
|
||||||
|
id: -1,
|
||||||
|
secondaryId: '-1',
|
||||||
|
documentId: -1,
|
||||||
|
templateId: null,
|
||||||
|
recipientId: -1,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { id: documentDataId } = await putFile({
|
const unsignedPdfBytes = await doc.save();
|
||||||
name: `${documentName}.pdf`,
|
|
||||||
type: 'application/pdf',
|
|
||||||
arrayBuffer: async () => Promise.resolve(signedPdfBuffer),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create document.
|
const signedPdfBuffer = await signPdf({ pdf: Buffer.from(unsignedPdfBytes) });
|
||||||
const document = await tx.document.create({
|
|
||||||
data: {
|
|
||||||
title: documentName,
|
|
||||||
status: DocumentStatus.COMPLETED,
|
|
||||||
documentDataId,
|
|
||||||
userId: serviceUser.id,
|
|
||||||
createdAt,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create recipient.
|
const { token } = await prisma.$transaction(
|
||||||
const recipient = await tx.recipient.create({
|
async (tx) => {
|
||||||
data: {
|
const token = alphaid();
|
||||||
documentId: document.id,
|
|
||||||
name: signer.name,
|
|
||||||
email: signer.email,
|
|
||||||
token,
|
|
||||||
signedAt: createdAt,
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
signingStatus: SigningStatus.SIGNED,
|
|
||||||
sendStatus: SendStatus.SENT,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create fields and signatures.
|
// Fetch service user who will be the owner of the document.
|
||||||
await Promise.all(
|
const serviceUser = await tx.user.findFirstOrThrow({
|
||||||
fields.map(async (field) => {
|
where: {
|
||||||
const insertedField = await tx.field.create({
|
email: SERVICE_USER_EMAIL,
|
||||||
data: {
|
},
|
||||||
documentId: document.id,
|
});
|
||||||
recipientId: recipient.id,
|
|
||||||
...mapField(field, signer),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
|
const { id: documentDataId } = await putFile({
|
||||||
await tx.signature.create({
|
name: `${documentName}.pdf`,
|
||||||
|
type: 'application/pdf',
|
||||||
|
arrayBuffer: async () => Promise.resolve(signedPdfBuffer),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create document.
|
||||||
|
const document = await tx.document.create({
|
||||||
|
data: {
|
||||||
|
title: documentName,
|
||||||
|
status: DocumentStatus.COMPLETED,
|
||||||
|
documentDataId,
|
||||||
|
userId: serviceUser.id,
|
||||||
|
createdAt,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create recipient.
|
||||||
|
const recipient = await tx.recipient.create({
|
||||||
|
data: {
|
||||||
|
documentId: document.id,
|
||||||
|
name: signer.name,
|
||||||
|
email: signer.email,
|
||||||
|
token,
|
||||||
|
signedAt: createdAt,
|
||||||
|
readStatus: ReadStatus.OPENED,
|
||||||
|
signingStatus: SigningStatus.SIGNED,
|
||||||
|
sendStatus: SendStatus.SENT,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create fields and signatures.
|
||||||
|
await Promise.all(
|
||||||
|
fields.map(async (field) => {
|
||||||
|
const insertedField = await tx.field.create({
|
||||||
data: {
|
data: {
|
||||||
fieldId: insertedField.id,
|
documentId: document.id,
|
||||||
signatureImageAsBase64,
|
|
||||||
typedSignature,
|
|
||||||
recipientId: recipient.id,
|
recipientId: recipient.id,
|
||||||
|
...mapField(field, signer),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return { document, token };
|
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
|
||||||
},
|
await tx.signature.create({
|
||||||
{
|
data: {
|
||||||
maxWait: 5000,
|
fieldId: insertedField.id,
|
||||||
timeout: 30000,
|
signatureImageAsBase64,
|
||||||
},
|
typedSignature,
|
||||||
);
|
recipientId: recipient.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const template = createElement(DocumentSelfSignedEmailTemplate, {
|
return { document, token };
|
||||||
documentName: documentName,
|
},
|
||||||
assetBaseUrl: NEXT_PUBLIC_WEBAPP_URL() || 'http://localhost:3000',
|
{
|
||||||
});
|
maxWait: 5000,
|
||||||
|
timeout: 30000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const [html, text] = await Promise.all([
|
const template = createElement(DocumentSelfSignedEmailTemplate, {
|
||||||
renderAsync(template),
|
documentName: documentName,
|
||||||
renderAsync(template, { plainText: true }),
|
assetBaseUrl: NEXT_PUBLIC_WEBAPP_URL() || 'http://localhost:3000',
|
||||||
]);
|
});
|
||||||
|
|
||||||
// Send email to signer.
|
const [html, text] = await Promise.all([
|
||||||
await mailer.sendMail({
|
renderAsync(template),
|
||||||
to: {
|
renderAsync(template, { plainText: true }),
|
||||||
address: signer.email,
|
]);
|
||||||
name: signer.name,
|
|
||||||
},
|
|
||||||
from: {
|
|
||||||
name: FROM_NAME,
|
|
||||||
address: FROM_ADDRESS,
|
|
||||||
},
|
|
||||||
subject: 'Document signed',
|
|
||||||
html,
|
|
||||||
text,
|
|
||||||
attachments: [{ content: signedPdfBuffer, filename: documentName }],
|
|
||||||
});
|
|
||||||
|
|
||||||
return token;
|
// Send email to signer.
|
||||||
|
await mailer.sendMail({
|
||||||
|
to: {
|
||||||
|
address: signer.email,
|
||||||
|
name: signer.name,
|
||||||
|
},
|
||||||
|
from: {
|
||||||
|
name: FROM_NAME,
|
||||||
|
address: FROM_ADDRESS,
|
||||||
|
},
|
||||||
|
subject: 'Document signed',
|
||||||
|
html,
|
||||||
|
text,
|
||||||
|
attachments: [{ content: signedPdfBuffer, filename: documentName }],
|
||||||
|
});
|
||||||
|
|
||||||
|
return token;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -56,6 +56,8 @@ export const templateRouter = router({
|
|||||||
recipients: input.recipients,
|
recipients: input.recipients,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to create this document. Please try again later.',
|
message: 'We were unable to create this document. Please try again later.',
|
||||||
|
|||||||
@ -21,6 +21,8 @@ export const webhookRouter = router({
|
|||||||
try {
|
try {
|
||||||
return await getWebhooksByUserId(ctx.user.id);
|
return await getWebhooksByUserId(ctx.user.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to fetch your webhooks. Please try again later.',
|
message: 'We were unable to fetch your webhooks. Please try again later.',
|
||||||
@ -36,6 +38,8 @@ export const webhookRouter = router({
|
|||||||
try {
|
try {
|
||||||
return await getWebhooksByTeamId(teamId, ctx.user.id);
|
return await getWebhooksByTeamId(teamId, ctx.user.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to fetch your webhooks. Please try again later.',
|
message: 'We were unable to fetch your webhooks. Please try again later.',
|
||||||
@ -55,6 +59,8 @@ export const webhookRouter = router({
|
|||||||
teamId,
|
teamId,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to fetch your webhook. Please try again later.',
|
message: 'We were unable to fetch your webhook. Please try again later.',
|
||||||
@ -77,6 +83,8 @@ export const webhookRouter = router({
|
|||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to create this webhook. Please try again later.',
|
message: 'We were unable to create this webhook. Please try again later.',
|
||||||
@ -96,6 +104,8 @@ export const webhookRouter = router({
|
|||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to create this webhook. Please try again later.',
|
message: 'We were unable to create this webhook. Please try again later.',
|
||||||
@ -116,6 +126,8 @@ export const webhookRouter = router({
|
|||||||
teamId,
|
teamId,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'We were unable to create this webhook. Please try again later.',
|
message: 'We were unable to create this webhook. Please try again later.',
|
||||||
|
|||||||
Reference in New Issue
Block a user