narinder1231's picture
improve error logging and error messages
d747060
raw
history blame contribute delete
716 Bytes
import { Request, Response } from 'express';
import { syncInvoicesService } from '../../shared/services/bills.service';
import { logger } from '../../utils/logger';
interface ErrorResponse {
response: {
data: {
userMessage: string;
errorCode: string;
errors?: Array<{ key: string; message: string }>;
}
}
}
export const syncInvoices = async (req: Request, res: Response): Promise<void> => {
try {
const result = await syncInvoicesService();
res.status(200).send(result);
} catch (error) {
logger.error('Error syncing Invoices');
logger.error(error);
res.status(500).send((error as Error).message);
}
};