Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: throw out human-readable errors for notifications (DAP-4765) #26

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class NotificationService {
return this._resolveNotification(
notificationId,
(resolution) => {
if (resolution.status === NotificationStatus.Viewed) {
throw new Error('Notification is already viewed')
}

resolution.status = NotificationStatus.Viewed
},
tx
Expand All @@ -60,6 +64,10 @@ export class NotificationService {
return this._resolveNotification(
notificationId,
(resolution) => {
if (resolution.status === NotificationStatus.Hidden) {
throw new Error('Notification is already hidden')
}

resolution.status = NotificationStatus.Hidden
},
tx
Expand All @@ -78,6 +86,13 @@ export class NotificationService {
throw new Error('Notification is hidden')
}

if (
resolution.result?.status === PullRequestStatus.Accepted ||
resolution.result?.status === PullRequestStatus.Rejected
) {
throw new Error('Notification has already been resolved')
}

// ToDo: check resolution.result

resolution.status = NotificationStatus.Viewed
Expand All @@ -99,7 +114,12 @@ export class NotificationService {
throw new Error('Notification is hidden')
}

// ToDo: check resolution.result
if (
resolution.result?.status === PullRequestStatus.Accepted ||
resolution.result?.status === PullRequestStatus.Rejected
) {
throw new Error('Notification has already been resolved')
}

resolution.status = NotificationStatus.Viewed
resolution.result = { status: PullRequestStatus.Rejected }
Expand Down
Loading