-
Notifications
You must be signed in to change notification settings - Fork 12
MPI - Se agrega try para SISA por si no funciona el servicio RENAPER #2101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
| } | ||
| } catch (error) { | ||
| // RENAPER caído, se continúa con SISA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Como buenas practicas dejar los catch vacíos puede generar problemas de mantenimiento, trazabilidad y mala comunicación con el cliente (quien consume la API) ya que si RENAPER falla, simplemente pasa al siguiente try y si SISA también falla, el catch lo ignora y devuelve ciudadanoRenaper (que podría ser null). Esto puede estar bien si la intención es continuar sin interrumpir la validación, pero no es suficiente si querés tener trazabilidad o informar correctamente al usuario. Lo ideal seria retornar mediante un error
} catch (error) {
throw new Error(Error al consultar RENAPER: ${error.message});
}
O simplemente: return next("mensaje de error").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corregido! Gracias por la sugerencia
| } | ||
| } catch (error) { | ||
| return null; | ||
| // Error también en SISA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem al comentario anterior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corregido.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A mi parecer no es conveniente poner en el primer catch un "throw new Error..." ya que esto detiene la ejecución y no pasaría al segundo try donde se evalúa por sisa. En todo caso lo que se puede hacer es loguear el error en caso de que falle por renaper y ahí si lanzar un error si también falla por SISA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buenas , corregido los catch
| } | ||
| } | ||
| } catch (error) { | ||
| throw new Error(`Error al consultar RENAPER: ${ error.message }`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nico, coincido con el comentario de Campe, en todo caso se puedo consolear el error dentro de la coleccion MPI, es decir podes importarla dentro del este archivo import { errorCiudadano} from '../mpi.log'; y luego podes reutilizarlo en esta linea de código.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buenas, se corrigió. Saludos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compa, perdon que fui poco claro en mi observacion. La idea sería evitar lanzar un throw new Error en este primer catch, ya que eso detiene la ejecución y no permite pasar al segundo try (SISA). En su lugar, podríamos aprovechar el recurso de logs y registrar el error antes de continuar.
Por ejemplo, algo así:
import { updateValidadosLog } from '../mpi.log';
import { userScheduler } from '../../../config.private';
catch (error) {
updateValidadosLog.error('consultaRenaper', { documento, sexo }, error, userScheduler);
}
De esa forma, el error queda registrado y la ejecución puede continuar normalmente con la consulta a SISA.
Requerimiento
MPI-453
Funcionalidad desarrollada
UserStories llegó a completarse
Requiere actualizaciones en la base de datos