airqo-platform / airqo-platform/AirQo-api
Refactor: Standardize error handling in role-permissions.util.js
- Lenguaje dominante
- JavaScript
- Estrellas
- 26
- Forks
- 24
- Merge medio
- 5 h 36 min
- PR fusionados (30 d)
- 81
Descripción
## Background
Currently, there are inconsistent patterns for error handling in `role-permissions.util.js`. The new `getDefaultGroupRole` function uses `throw new HttpError` while other functions use `next(new HttpError)`.
## Proposed Change
Standardize error handling across all functions to use `throw new HttpError` pattern:
```diff
} catch (error) {
logger.error(`🐛🐛 Internal Server Error ${error.message}`);
- next(
- new HttpError(
- "Internal Server Error",
- httpStatus.INTERNAL_SERVER_ERROR,
- { message: error.message }
- )
- );
+ throw new HttpError(
+ "Internal Server Error",
+ httpStatus.INTERNAL_SERVER_ERROR,
+ { message: error.message }
+ );
}
```
## Benefits
- Consistent error handling pattern throughout the file
- Cleaner error propagation
- Better alignment with JavaScript's error handling mechanisms
## References
- PR: #4439
- Discussion: https://github.com/airqo-platform/AirQo-api/pull/4439#discussion_r1957321666
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.