FEAT: Connection test creating connection

- If any error occurs, connection is deleted
 - If operation_result is false, connection is deleted
This commit is contained in:
Gabriel Rosa
2022-08-03 11:31:57 -03:00
parent a1cdad42ab
commit 688bf49f3b
11 changed files with 201 additions and 124 deletions
+26 -1
View File
@@ -171,6 +171,31 @@ export function EnrichErrorCode(code: string) {
message: 'Id encontra-se num formato inválido',
code,
};
case ErrorCodes.CONNECTION_TEST.ERROR:
return {
statusCode: HttpStatus.BAD_REQUEST,
error: 'Erro ao realizar o teste',
message: 'Verifique os dados de conexão e tente novamente',
code,
};
case ErrorCodes.CONNECTION_TEST.EXPIRED:
return {
statusCode: HttpStatus.NOT_FOUND,
error: 'Teste de conexão expirado',
message: 'Favor realizar novo teste',
code,
};
case ErrorCodes.CONNECTION_TEST.TIMEOUT:
return {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Tempo limite excedido',
message:
'O teste excedeu o tempo limite. Verifique os dados de conexão e tente novamente',
code,
};
case ErrorCodes.INTERNAL:
case ErrorCodes.UNKNOWN:
default:
@@ -193,7 +218,7 @@ export default class ErrorBuilder extends HttpException {
constructor(code: string | RpcException = '') {
if (typeof code !== 'string') {
logger.log(code?.stack);
code = (code as any).details as string;
code = (code as any)?.details as string;
} else {
logger.log(code);
}
+8
View File
@@ -38,6 +38,13 @@ const TERMS_OF_USE = {
REQUIRED: 'TERMS_OF_USE.REQUIRED',
};
const CONNECTION_TEST = {
ERROR: 'CONNECTION_TEST.ERROR',
EXPIRED: 'CONNECTION_TEST.EXPIRED',
TIMEOUT: 'CONNECTION_TEST.TIMEOUT',
UNKNOWN: 'CONNECTION_TEST.UNKNOWN',
};
const ErrorCodes = {
UNKNOWN: 'UNKNOWN',
RATE_LIMIT: 'RATE_LIMIT',
@@ -47,6 +54,7 @@ const ErrorCodes = {
TERMS_OF_USE,
USER,
CUSTOMER,
CONNECTION_TEST,
};
export default ErrorCodes;