Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

updated error handling and log levels for ShiftService#86

Merged
algotyrnt merged 2 commits intomainfrom
test
Jun 21, 2025
Merged

updated error handling and log levels for ShiftService#86
algotyrnt merged 2 commits intomainfrom
test

Conversation

@EranTimothy-dev
Copy link
Contributor

@EranTimothy-dev EranTimothy-dev commented Jun 21, 2025

claimShift method updates

  • Updated error handling in claim shift method to help with separate test cases and useful messages based on exception, for runtime exceptions and threading exception separately.
  • usage of method level variable to store error message and format the message based on exception.

general changes

  • Changed the log level from error to warn for logs that weren't an anomaly like row not being in the database.
  • Removed commented out lines of code in LeaveServiceTest class.

@EranTimothy-dev EranTimothy-dev self-assigned this Jun 21, 2025
@EranTimothy-dev EranTimothy-dev added the enhancement New feature or request label Jun 21, 2025
@algotyrnt
Copy link
Member

This pull request includes several changes to improve logging consistency, enhance error handling, and clean up unit test code. The most significant updates involve replacing logger.error with logger.warn for non-critical errors, refining exception messages for better clarity, and removing unused or commented-out code in tests.

Logging Improvements:

  • Replaced logger.error with logger.warn for non-critical situations, such as when shifts or users are not found, across multiple methods in ShiftService. This ensures that the log level better reflects the severity of the issue. ([[1]](https://github.com/ShiftSL/backend/pull/86/files#diff-628a89f702a414d5e41cac2beac81aa3104f7f36f8da73bdec95a47832187c88L68-R76), [[2]](https://github.com/ShiftSL/backend/pull/86/files#diff-628a89f702a414d5e41cac2beac81aa3104f7f36f8da73bdec95a47832187c88L115-R128), [[3]](https://github.com/ShiftSL/backend/pull/86/files#diff-628a89f702a414d5e41cac2beac81aa3104f7f36f8da73bdec95a47832187c88L126-R139))

Error Handling Enhancements:

  • Refined exception messages in claimShift to provide more detailed and user-friendly error descriptions. Added logic to include a lock-related error message when applicable. ([src/main/java/com/shiftsl/backend/Service/ShiftService.javaL95-R119](https://github.com/ShiftSL/backend/pull/86/files#diff-628a89f702a414d5e41cac2beac81aa3104f7f36f8da73bdec95a47832187c88L95-R119))

Unit Test Code Cleanup:

  • Removed unused or commented-out ArgumentCaptor declarations in LeaveServiceTest to clean up the code and improve readability. ([[1]](https://github.com/ShiftSL/backend/pull/86/files#diff-99247d88923a0e0f2c05f38790ffa64d2ecda8546fc093aa96c1b7029d01a5ceL51), [[2]](https://github.com/ShiftSL/backend/pull/86/files#diff-99247d88923a0e0f2c05f38790ffa64d2ecda8546fc093aa96c1b7029d01a5ceL166), [[3]](https://github.com/ShiftSL/backend/pull/86/files#diff-99247d88923a0e0f2c05f38790ffa64d2ecda8546fc093aa96c1b7029d01a5ceL191))
  • Simplified the requestLeaveTest by removing an unused variable assignment for the result of the method under test. ([src/test/java/com/shiftsl/backend/unittests/Service/LeaveServiceTest.javaL133-R132](https://github.com/ShiftSL/backend/pull/86/files#diff-99247d88923a0e0f2c05f38790ffa64d2ecda8546fc093aa96c1b7029d01a5ceL133-R132))

@algotyrnt algotyrnt merged commit f8fe9a7 into main Jun 21, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants