feat: update error log

This commit is contained in:
Zamitto 2024-10-21 15:10:07 -03:00
parent df5f82d47f
commit 6ef1135ba2
3 changed files with 8 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import { HydraApi } from "../hydra-api";
import { getUnlockedAchievements } from "@main/events/user/get-unlocked-achievements";
import { Game } from "@main/entity";
import { achievementsLogger } from "../logger";
import { SubscriptionRequiredError } from "@shared";
const saveAchievementsOnLocal = async (
objectId: string,
@ -141,7 +142,10 @@ export const mergeAchievements = async (
);
})
.catch((err) => {
achievementsLogger.error(err);
if (err! instanceof SubscriptionRequiredError) {
achievementsLogger.error(err);
}
return saveAchievementsOnLocal(
game.objectID,
game.shop,

View File

@ -8,10 +8,7 @@ import url from "url";
import { uploadGamesBatch } from "./library-sync";
import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
import { logger } from "./logger";
import {
UserNotLoggedInError,
UserWithoutCloudSubscriptionError,
} from "@shared";
import { UserNotLoggedInError, SubscriptionRequiredError } from "@shared";
// import { omit } from "lodash-es";
import { appVersion } from "@main/constants";
import { omit } from "lodash-es";
@ -40,7 +37,6 @@ export class HydraApi {
}
private static async hasCloudSubscription() {
// TODO change this later, this is just a quick test
return userSubscriptionRepository
.findOne({ where: { id: 1 } })
.then((userSubscription) => {
@ -262,7 +258,7 @@ export class HydraApi {
if (needsCloud) {
if (!(await this.hasCloudSubscription())) {
throw new UserWithoutCloudSubscriptionError();
throw new SubscriptionRequiredError();
}
}
}

View File

@ -10,7 +10,7 @@ export class UserNotLoggedInError extends Error {
}
}
export class UserWithoutCloudSubscriptionError extends Error {
export class SubscriptionRequiredError extends Error {
constructor() {
super("user does not have hydra cloud subscription");
this.name = "UserWithoutCloudSubscriptionError";