improvement: started translation of backend errors

This commit is contained in:
canove
2020-10-13 06:50:00 -03:00
parent 09f8ef9be0
commit 011d8d5dfe
15 changed files with 100 additions and 54 deletions

View File

@@ -8,9 +8,7 @@ const CheckContactOpenTickets = async (contactId: number): Promise<void> => {
});
if (ticket) {
throw new AppError(
"There's already an open or pending ticket for this contact."
);
throw new AppError("ERR_OTHER_OPEN_TICKET");
}
};

View File

@@ -7,7 +7,7 @@ const GetDefaultWhatsApp = async (): Promise<Whatsapp> => {
});
if (!defaultWhatsapp) {
throw new AppError("No default WhatsApp found. Check Connection page.");
throw new AppError("ERR_NO_WAPP_FOUND");
}
return defaultWhatsapp;

View File

@@ -1,6 +1,5 @@
import { Client as Session } from "whatsapp-web.js";
import { getWbot } from "../libs/wbot";
import AppError from "../errors/AppError";
import GetDefaultWhatsApp from "./GetDefaultWhatsApp";
import Ticket from "../models/Ticket";
@@ -8,9 +7,6 @@ const GetTicketWbot = async (ticket: Ticket): Promise<Session> => {
if (!ticket.whatsappId) {
const defaultWhatsapp = await GetDefaultWhatsApp();
if (!defaultWhatsapp) {
throw new AppError("No default WhatsApp found. Check Connection page.");
}
await ticket.$set("whatsapp", defaultWhatsapp);
}