Improve type safety and fallback logic in isDutyLeaveConstraintError#347
Merged
Improve type safety and fallback logic in isDutyLeaveConstraintError#347
Conversation
Merged
…rror Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Enhance error handling in AddAttendanceDialog
Improve type safety and fallback logic in isDutyLeaveConstraintError
Feb 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines isDutyLeaveConstraintError to be safer under strict TypeScript settings while improving its fallback behavior when details exists but isn’t a nested object.
Changes:
- Changed the function parameter type to
unknownand added runtime narrowing before property access. - Updated nested
detailshandling to only inspectdetails.code/details.hintwhendetailsis an object, avoiding blocking message-based fallback. - Added a regression test covering
detailsas a non-object value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lib/error-handling.ts | Tightens input typing to unknown, adds runtime guards, and fixes fallback flow when details is truthy but not an object. |
| src/lib/tests/duty-leave-error-handling.test.ts | Adds test coverage for details being a non-object while still allowing message fallback detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
devakesu
added a commit
that referenced
this pull request
Feb 12, 2026
* chore: enhance error handling in AddAttendanceDialog * Improve type safety and fallback logic in isDutyLeaveConstraintError (#347) * Initial plan * fix: improve type safety and error handling in isDutyLeaveConstraintError Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses review feedback on duty-leave constraint error detection: parameter type collapsed to
any, and nesteddetailscheck prevented message fallback.Type Safety
DatabaseError | any | null | undefinedtounknowntypeofchecks and explicit castingNested Error Detection
detailsproperty now validated as object before accessing nested fieldsdetailsis non-object (e.g., string)Before:
After:
Test Coverage
detailsas non-object value to prevent regression💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.