Skip to content

[JITERA] Refactor deleteBook Function in Controller and Service

chi le requested to merge feat/refactor-deleteBook-1749550265 into main

Created by: chi-jitera

Overview

This pull request refactors the deleteBook function found in both the bookController.js and bookService.js files. The goal of this refactoring is to enhance error handling, improve logging, and optimize database interactions.

Changes Made

Refactored deleteBook in bookController.js

  • Improved error handling by returning specific HTTP status codes based on the outcome of the deletion process.
  • Added logging to capture the flow of the request and any errors that occur, which aids in debugging and monitoring.

Refactored deleteBook in bookService.js

  • Enhanced error handling to throw specific errors when a book is not found, allowing the controller to respond appropriately.
  • Implemented logging for successful deletions and errors, providing better traceability of operations and issues.
  • Ensured consistent error messages for unexpected errors to improve the user experience and facilitate troubleshooting.

These changes aim to create a more robust and maintainable codebase while providing better feedback to users and developers alike.

Merge request reports