Skip to content

Commit

Permalink
feat/#214 fix throw error exception
Browse files Browse the repository at this point in the history
  • Loading branch information
DungNguyen2003 committed Jun 11, 2023
1 parent 960beb2 commit d80c9af
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/apis/v1/popup/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ export const createPopup = async (input: DocumentDto) => {

return data;
} catch (error) {
throw new HttpException(
400,
error?.message || ErrorCodes.BAD_REQUEST.MESSAGE,
error?.code || ErrorCodes.BAD_REQUEST.CODE
);
logger.error(`Error creating popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};

Expand All @@ -28,6 +25,7 @@ export const deletePopup = async (id: string) => {
logger.info('Popup deleted successfully');
return data;
} catch (error) {
logger.error(`Error deleting popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};
Expand All @@ -41,6 +39,7 @@ export const revokedPopup = async (id: string) => {
logger.info(`Popup revoked successfully: ${data}`);
return result;
} catch (error) {
logger.error(`Error revoking popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};
Expand Down Expand Up @@ -72,6 +71,7 @@ export const getPopups = async (urlParams: URLParams) => {
},
};
} catch (error) {
logger.error(`Error getting popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};
Expand All @@ -87,6 +87,7 @@ export const getPopupsByDateRange = async () => {
logger.info('Popups fetched successfully');
return data;
} catch (error) {
logger.error(`Error getting popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};
Expand All @@ -103,6 +104,7 @@ export const updatePopup = async (id: string, input: UpdatePopupDto) => {
logger.info('Popups updated successfully');
return data;
} catch (error) {
logger.error(`Error updating popup : ${error}`);
throw new HttpException(400, ErrorCodes.BAD_REQUEST.MESSAGE, ErrorCodes.BAD_REQUEST.CODE);
}
};

0 comments on commit d80c9af

Please sign in to comment.