-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: do not log known errors in handlers
- Loading branch information
Showing
22 changed files
with
44 additions
and
118 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/download/abort-download-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { downloadDemoQueue } from 'csdm/server/download-queue'; | ||
import { getErrorCodeFromError } from '../../../get-error-code-from-error'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function abortDownloadHandler(matchId: string) { | ||
try { | ||
downloadDemoQueue.abortDownload(matchId); | ||
return Promise.resolve(); | ||
} catch (error) { | ||
logger.error(`Error while aborting download with match id ${matchId}`); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, `Error while aborting download with match id ${matchId}`); | ||
} | ||
} |
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/download/abort-downloads-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { downloadDemoQueue } from 'csdm/server/download-queue'; | ||
import { getErrorCodeFromError } from '../../../get-error-code-from-error'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function abortDownloadsHandler() { | ||
try { | ||
downloadDemoQueue.abortDownloads(); | ||
return Promise.resolve(); | ||
} catch (error) { | ||
logger.error('Error while aborting downloads'); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, 'Error while aborting downloads'); | ||
} | ||
} |
This file contains 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
5 changes: 2 additions & 3 deletions
5
src/server/handlers/renderer-process/map/delete-map-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import type { Map } from 'csdm/common/types/map'; | ||
import { deleteMap } from 'csdm/node/database/maps/delete-map'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function deleteMapHandler(map: Map) { | ||
try { | ||
await deleteMap(map); | ||
} catch (error) { | ||
logger.error('Error while deleting map'); | ||
logger.error(error); | ||
throw error; | ||
handleError(error, 'Error while deleting map'); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
10 changes: 2 additions & 8 deletions
10
src/server/handlers/renderer-process/player/fetch-player-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
import { fetchPlayer } from 'csdm/node/database/player/fetch-player'; | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import type { FetchPlayerFilters } from 'csdm/node/database/player/fetch-player-filters'; | ||
import { ErrorCode } from 'csdm/common/error-code'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function fetchPlayerHandler(payload: FetchPlayerFilters) { | ||
try { | ||
const player = await fetchPlayer(payload); | ||
|
||
return player; | ||
} catch (error) { | ||
const errorCode = getErrorCodeFromError(error); | ||
if (errorCode === ErrorCode.UnknownError) { | ||
logger.error(`Error while fetching player with steamID ${payload.steamId}`); | ||
logger.error(error); | ||
} | ||
throw errorCode; | ||
handleError(error, `Error while fetching player with steamID ${payload.steamId}`); | ||
} | ||
} |
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/player/fetch-players-table-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import { fetchPlayersTable } from 'csdm/node/database/players/fetch-players-table'; | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import type { PlayersTableFilter } from 'csdm/node/database/players/players-table-filter'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function fetchPlayersHandler(filter: PlayersTableFilter) { | ||
try { | ||
const players = await fetchPlayersTable(filter); | ||
|
||
return players; | ||
} catch (error) { | ||
logger.error('Error while fetching players table'); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, 'Error while fetching players table'); | ||
} | ||
} |
This file contains 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
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/tags/delete-tag-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import { deleteTag } from 'csdm/node/database/tags/delete-tag'; | ||
import { removeTagIdFromSettings } from 'csdm/node/settings/remove-tag-id-from-settings'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function deleteTagHandler(tagId: string) { | ||
try { | ||
await deleteTag(tagId); | ||
await removeTagIdFromSettings(tagId); | ||
} catch (error) { | ||
logger.error('Error while deleting tag'); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, 'Error while deleting tag'); | ||
} | ||
} |
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/tags/insert-tag-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import type { Tag } from 'csdm/common/types/tag'; | ||
import { insertTag } from 'csdm/node/database/tags/insert-tag'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function insertTagHandler(tag: Omit<Tag, 'id'>) { | ||
try { | ||
const newTag = await insertTag(tag); | ||
|
||
return newTag; | ||
} catch (error) { | ||
logger.error('Error while inserting tag'); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, 'Error while inserting tag'); | ||
} | ||
} |
7 changes: 2 additions & 5 deletions
7
src/server/handlers/renderer-process/tags/update-tag-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import type { Tag } from 'csdm/common/types/tag'; | ||
import { updateTag } from 'csdm/node/database/tags/update-tag'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function updateTagHandler(tag: Tag) { | ||
try { | ||
await updateTag(tag); | ||
} catch (error) { | ||
logger.error('Error while updating tag'); | ||
logger.error(error); | ||
const errorCode = getErrorCodeFromError(error); | ||
throw errorCode; | ||
handleError(error, 'Error while updating tag'); | ||
} | ||
} |
10 changes: 2 additions & 8 deletions
10
src/server/handlers/renderer-process/team/fetch-team-handler.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
import { ErrorCode } from 'csdm/common/error-code'; | ||
import { fetchTeam } from 'csdm/node/database/team/fetch-team'; | ||
import { getErrorCodeFromError } from 'csdm/server/get-error-code-from-error'; | ||
import type { FetchTeamFilters } from 'csdm/node/database/team/fetch-team-filters'; | ||
import { handleError } from '../../handle-error'; | ||
|
||
export async function fetchTeamHandler(payload: FetchTeamFilters) { | ||
try { | ||
const team = await fetchTeam(payload); | ||
|
||
return team; | ||
} catch (error) { | ||
const errorCode = getErrorCodeFromError(error); | ||
if (errorCode === ErrorCode.UnknownError) { | ||
logger.error(`Error while fetching team with name ${payload.name}`); | ||
logger.error(error); | ||
} | ||
throw errorCode; | ||
handleError(error, `Error while fetching team with name ${payload.name}`); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.