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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user