🧑‍💻 (dev) improve error handler

This commit is contained in:
Rafi Arrafif
2025-09-09 00:26:53 +07:00
parent cd8a0490c4
commit 4c4ae0385b
2 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { AppError } from "../../../../helpers/error/instances/app";
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
import { UserHeaderInformation } from "../../../../helpers/http/userHeader/getUserHeaderInformation/types";
import { GithubCallbackUserData } from "../../auth.types";
import { githubProvider } from "../../providers/github.provider";
@ -54,6 +54,6 @@ export const githubCallbackService = async (
userHeaderInfo
);
} catch (error) {
return new AppError(500, "Authentication service error", error);
ErrorForwarder(error, 500, "Authentication service error");
}
};

View File

@ -1,10 +1,15 @@
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
import { userModel } from "../../user.model";
import { createUserViaRegisterInput } from "../../user.types";
export const createUserViaRegisterRepository = async (
payload: createUserViaRegisterInput
) => {
return await userModel.create({
data: payload,
});
try {
return await userModel.create({
data: payload,
});
} catch (error) {
ErrorForwarder(error);
}
};