chore(medusa): Move formatException to the errorHandler to be always applied and not have to apply it manually (#2467)

**What**

Move the usage of the formatException to the errorHandler level in order to not have to try catch here and there to apply it. Also make our error handling uniformed and avoid forgetting to apply it.

FIXES CORE-721
This commit is contained in:
Adrien de Peretti
2022-10-19 16:22:42 +00:00
committed by GitHub
parent fcfb7d167b
commit 2f00bd100a
8 changed files with 184 additions and 201 deletions
@@ -4,7 +4,7 @@ export enum PostgresError {
DUPLICATE_ERROR = "23505",
FOREIGN_KEY_ERROR = "23503",
}
export const formatException = (err): Error => {
export const formatException = (err): MedusaError => {
switch (err.code) {
case PostgresError.DUPLICATE_ERROR:
return new MedusaError(