Closed jonathanfallon closed 5 months ago
The recent changes focus on streamlining error handling, enhancing code readability, and improving error message consistency across the codebase. These updates aim to make the code more maintainable and easier to debug by refining error logging, reordering imports, adjusting function names, and updating error messages for clarity.
Files | Changes Summary |
---|---|
.../validator/AjvValidator.ts , .../validator/ValidatorMiddleware.ts |
Reordered imports, added InvalidParamsException , updated error handling, introduced mapErrors , and simplified error handling. |
.../services/acquisition/actions/CreateJourneyAction.spec.ts , .../services/acquisition/actions/CreateJourneyAction.ts |
Reordered imports, adjusted function names, fixed typos, added logging, and refined error messages. |
.../services/cee/actions/ImportCeeAction.integration.spec.ts , .../services/cee/actions/ImportCeeAction.ts |
Reordered imports, moved declarations, adjusted error message checks, and improved error message structure. |
.../services/cee/actions/ImportCeeIdentityAction.integration.spec.ts |
Reordered imports, updated import order, adjusted declarations, and modified error message access in test cases. |
.../services/cee/actions/RegisterCeeAction.integration.spec.ts |
Reordered imports, adjusted error message formatting, and updated error data handling in test cases. |
.../services/cee/actions/SimulateCeeAction.integration.spec.ts |
Updated error message formatting in test assertions, removed a logging statement, and improved error handling. |
shared/cee/common/ceeSchema.ts |
Updated error messages for various schemas related to phone numbers, driving licenses, timestamps, IDs, and status for clarity and consistency. |
🐇 Poem by CodeRabbit
In the realm of code where the rabbits play,
Errors vanish as they bounce away.
Lines now shine with a polished sheen,
Debugging made easy, like a serene dream.
Let's dance in the code under the moon's soft light,
With each update, making our code bright! 🌟
api/src/ilos/validator/ValidatorMiddleware.ts (1)
`15-15`: Ensure that `InvalidParamsException` is properly imported and used here since the direct throwing of this exception is a significant change in error handling.api/src/pdc/services/cee/actions/ImportCeeAction.ts (1)
`31-31`: The updated error message format for the `datetime` field enhances clarity and should help in debugging. Ensure that the `timestampSchema` is correctly defined with the `errorMessage` property.shared/cee/common/ceeSchema.ts (4)
`29-29`: The updated error message for the `phoneTruncSchema` improves clarity. Ensure consistency across all schemas. --- `75-75`: The updated error message for the `drivingLicenseSchema` is clearer and more specific, which should help in validation error reporting. --- `82-82`: The error message for `timestampSchema` now clearly specifies the required format, which is beneficial for validation purposes. --- `91-91`: The error message for `operatorJourneyIdSchema` has been clarified. This is crucial for debugging and validation.api/src/pdc/services/cee/actions/ImportCeeIdentityAction.integration.spec.ts (5)
`56-56`: The updated error message access in the test case ensures that specific validation errors are correctly captured and asserted. --- `66-66`: Correctly accessing the `lastNameTruncSchema.errorMessage` in the test ensures that specific error messages are used, which aids in precise testing. --- `76-76`: Using `ceeJourneyTypeEnumSchema.errorMessage` in the test case is a good practice as it ensures that the error messages are consistent with the schema definitions. --- `86-86`: The test case correctly uses `timestampSchema.errorMessage` for validation errors, which is crucial for maintaining consistency in error reporting. --- `96-96`: Accessing `phoneTruncSchema.errorMessage` in the test case ensures that the error messages are consistent and accurate.api/src/pdc/services/cee/actions/ImportCeeAction.integration.spec.ts (5)
`57-57`: The updated error message access in the test case ensures that specific validation errors are correctly captured and asserted. --- `67-67`: Correctly accessing the `lastNameTruncSchema.errorMessage` in the test ensures that specific error messages are used, which aids in precise testing. --- `77-77`: Using `ceeJourneyTypeEnumSchema.errorMessage` in the test case is a good practice as it ensures that the error messages are consistent with the schema definitions. --- `87-87`: The test case correctly uses `timestampSchema.errorMessage` for validation errors, which is crucial for maintaining consistency in error reporting. --- `97-97`: Accessing `phoneTruncSchema.errorMessage` in the test case ensures that the error messages are consistent and accurate.api/src/pdc/services/cee/actions/SimulateCeeAction.integration.spec.ts (4)
`82-82`: Updating the error message format in the test assertion for `last_name_trunc` improves clarity and consistency with schema definitions. --- `92-92`: The updated error message format for `journey_type` in the test assertion aligns with the schema and enhances error clarity. --- `102-102`: The error message format for `driving_license` in the test assertion is updated for better clarity and consistency. --- `112-112`: The test assertion for `phone_trunc` uses the updated error message format, ensuring consistency and clarity in error reporting.api/src/pdc/services/cee/actions/RegisterCeeAction.integration.spec.ts (6)
`74-74`: The updated error message format for `last_name_trunc` in the test assertion improves clarity and consistency with schema definitions. --- `84-84`: The updated error message format for `journey_type` in the test assertion aligns with the schema and enhances error clarity. --- `94-94`: The error message format for `driving_license` in the test assertion is updated for better clarity and consistency. --- `104-107`: The test assertion for `operator_journey_id` uses the updated error message format, ensuring consistency and clarity in error reporting. The use of `t.deepEqual` for array comparison is appropriate here. --- `117-117`: The test assertion for `datetime` uses the updated error message format, ensuring consistency and clarity in error reporting. --- `127-127`: The test assertion for `phone_trunc` uses the updated error message format, ensuring consistency and clarity in error reporting.
return InvalidParamsException when AJV fails
Summary by CodeRabbit