mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: Adjusts in return errors
This commit is contained in:
parent
f74a7e87bd
commit
f95d938fb6
@ -2,7 +2,6 @@ import { HttpStatus } from '../whatsapp/routers/index.router';
|
|||||||
|
|
||||||
export class BadRequestException {
|
export class BadRequestException {
|
||||||
constructor(...objectError: any[]) {
|
constructor(...objectError: any[]) {
|
||||||
console.log('BadRequestException', objectError);
|
|
||||||
throw {
|
throw {
|
||||||
status: HttpStatus.BAD_REQUEST,
|
status: HttpStatus.BAD_REQUEST,
|
||||||
error: 'Bad Request',
|
error: 'Bad Request',
|
||||||
|
13
src/main.ts
13
src/main.ts
@ -48,7 +48,14 @@ function bootstrap() {
|
|||||||
app.use(
|
app.use(
|
||||||
(err: Error, req: Request, res: Response, next: NextFunction) => {
|
(err: Error, req: Request, res: Response, next: NextFunction) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(err['status'] || 500).json(err);
|
return res.status(err['status'] || 500).json({
|
||||||
|
status: 'ERROR',
|
||||||
|
error: err['error'] || 'Internal Server Error',
|
||||||
|
response: {
|
||||||
|
message: err['message'] || 'Internal Server Error',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@ -58,8 +65,10 @@ function bootstrap() {
|
|||||||
|
|
||||||
res.status(HttpStatus.NOT_FOUND).json({
|
res.status(HttpStatus.NOT_FOUND).json({
|
||||||
status: HttpStatus.NOT_FOUND,
|
status: HttpStatus.NOT_FOUND,
|
||||||
message: `Cannot ${method.toUpperCase()} ${url}`,
|
|
||||||
error: 'Not Found',
|
error: 'Not Found',
|
||||||
|
response: {
|
||||||
|
message: `Cannot ${method.toUpperCase()} ${url}`,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
@ -930,7 +930,6 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async receiveWebhook(instance: InstanceDto, body: any) {
|
public async receiveWebhook(instance: InstanceDto, body: any) {
|
||||||
console.log(body);
|
|
||||||
try {
|
try {
|
||||||
this.logger.verbose('receive webhook to chatwoot instance: ' + instance.instanceName);
|
this.logger.verbose('receive webhook to chatwoot instance: ' + instance.instanceName);
|
||||||
const client = await this.clientCw(instance);
|
const client = await this.clientCw(instance);
|
||||||
|
Loading…
Reference in New Issue
Block a user