Skip to content

Commit

Permalink
remove exception
Browse files Browse the repository at this point in the history
  • Loading branch information
balanza committed Apr 15, 2021
1 parent c25f4c5 commit 02689b3
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions utils/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,14 @@ const successNH = (): NHResultSuccess =>
kind: "SUCCESS"
});

/* eslint-disable arrow-body-style */
export const notify = (
notificationHubService: NotificationHubService,
installationId: NonEmptyString,
payload: NotifyPayload
): TaskEither<Error, NHResultSuccess> => {
return tryCatch(
() => {
return new Promise<NHResultSuccess>((resolve, reject) =>
): TaskEither<Error, NHResultSuccess> =>
tryCatch(
() =>
new Promise<NHResultSuccess>((resolve, reject) =>
notificationHubService.send(
toNotificationTag(installationId),
payload,
Expand All @@ -169,12 +168,10 @@ export const notify = (
`Error while sending notification to NotificationHub|${error.message}`
)
)
);
},
),
errs =>
new Error(`Error while sending notification to NotificationHub|${errs}`)
);
};

export const createOrUpdateInstallation = (
notificationHubService: NotificationHubService,
Expand All @@ -197,8 +194,8 @@ export const createOrUpdateInstallation = (
};

return tryCatch(
() => {
return new Promise<NHResultSuccess>((resolve, reject) =>
() =>
new Promise<NHResultSuccess>((resolve, reject) =>
notificationHubService.createOrUpdateInstallation(
azureInstallationOptions,
(err, _) =>
Expand All @@ -209,8 +206,7 @@ export const createOrUpdateInstallation = (
${installationId}] [${err.message}]`
)
)
);
},
),
errs =>
new Error(
`Error while creating or updating installation on NotificationHub [${installationId}] [${errs}]`
Expand All @@ -221,22 +217,20 @@ export const createOrUpdateInstallation = (
export const deleteInstallation = (
notificationHubService: NotificationHubService,
installationId: NonEmptyString
): TaskEither<Error, NHResultSuccess> => {
return tryCatch(
() => {
return new Promise<NHResultSuccess>((resolve, reject) =>
): TaskEither<Error, NHResultSuccess> =>
tryCatch(
() =>
new Promise<NHResultSuccess>((resolve, reject) =>
notificationHubService.deleteInstallation(installationId, (e, _) =>
e == null
? resolve(successNH())
: reject(
`Error while deleting installation on NotificationHub [${installationId}] [${e.message}]`
)
)
);
},
),
errs =>
new Error(
`Error while deleting installation on NotificationHub [${installationId}] [${errs}]`
)
);
};

0 comments on commit 02689b3

Please sign in to comment.