1.0.13 • Published 2 years ago
@twe_apollo/error-helper v1.0.13
About The Project
This library is an error handling library that the TRT World engineering team can use in their projects. This library is designed to help both clients and developers quickly understand errors encountered in the code, and it includes custom error codes for this purpose.
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js.
If this is a brand new project, make sure to create a package.json first with the npm init command.
This library is a private library, and before downloading it, you should perform the npm login process.
npm login
npm login
Installation is done using the npm install command:
npm i @twe_apollo/error-helper
Error List
ERROR CODE | ERROR MESSAGE | ERROR PREFIX | ERROR DESCRIPTION |
---|---|---|---|
0 | Undefined error | UNDEFINED_ERROR | We can use this error when I couldn't find related error |
1 | Health check error | HEALTH_CHECK_ERROR | This error occurs if there is an error during health check |
2 | Worker errors | WORKER_ERROR | This error occurs if there is an error in the worker |
3 | Worker listener errors | WORKER_LISTENER_ERROR | This error occurs if there is an error in worker listener |
4 | API settings errors | API_SETTING_ERROR | This error occurs if there is an error in API settings |
1000 | User register error | USER_REGISTER_ERROR | This error occurs if the registration of a user fails |
1001 | User login error | USER_LOGIN_ERROR | This error occurs if the login of a user fails |
1002 | User logout error | USER_LOGOUT_ERROR | This error occurs if the logout of a user fails |
1003 | User reset password error | USER_RESET_PASSWORD_ERROR | This error occurs if resetting a user's password fails |
1004 | User create new password error | USER_CREATE_NEW_PASSWORD_ERROR | This error occurs if creating a new password for a user fails |
1005 | Seed create user error | SEED_CREATE_USER_ERROR | This error occurs if creating users as seed fails |
1006 | Seed create config error | SEED_CREATE_CONFIG_ERROR | This error occurs if creating config as seed fails |
2000 | There is no connection string | DATABASE_CONNECTION_STRING_NOT_FOUND | This error occurs if there is no connection string |
2001 | Database connection failed | DATABASE_CONNECTION_ERROR | This error occurs if the server couldn't connect to the database |
2002 | Failed to insert data into the database | DATABASE_INSERT_ERROR | This error occurs if inserting data into the database fails |
2003 | Failed to update data in the database | DATABASE_UPDATE_ERROR | This error occurs if updating data in the database fails |
2004 | Failed to delete data from the database | DATABASE_DELETE_ERROR | This error occurs if deleting data from the database fails |
2005 | The requested record was not found. | DATABASE_RECORD_NOT_FOUND | This error occurs if the requested record was not found |
2006 | Permission denied for this operation | DATABASE_PERMISSION_DENIED | This error occurs if permission is denied for this operation |
2007 | An unknown database error occurred. | DATABASE_UNKNOWN_ERROR | This error occurs if an unknown database error occurs |
2008 | Failed to get data from the database | DATABASE_FIND_ERROR | This error occurs if getting data from the database fails |
3000 | Failed to add task to queue | QUEUE_TASK_INSERT_ERROR | This error occurs if adding a task to the queue fails |
3001 | Failed to restart the queue | QUEUE_RESTART_ERROR | This error occurs if restarting the queue fails |
3002 | Failed to stop the queue | QUEUE_STOP_ERROR | This error occurs if stopping the queue fails |
3003 | Failed to pause the queue | QUEUE_PAUSE_ERROR | This error occurs if pausing the queue fails |
3004 | Failed to read all queues | QUEUE_READ_ERROR | This error occurs if reading all queues fails |
3005 | Failed to get all cronjobs | QUEUE_CRONJOB_GET_ERROR | This error occurs if getting all cronjobs fails |
3006 | Failed to restart cronjob | QUEUE_CRONJOB_RESTART_ERROR | This error occurs if restarting a cronjob fails |
3007 | Failed to stop cronjob | QUEUE_CRONJOB_STOP_ERROR | This error occurs if stopping a cronjob fails |
3008 | Failed to get config error | QUEUE_SERVICE_GET_CONFIG_ERROR | This error occurs if getting config from message API fails |
4000 | Failed to create a data in internal service | SERVICE_INTERNAL_CREATE_DATA_ERROR | This error occurs if creating a data in an internal service fails |
4001 | Failed to get data from an internal service | SERVICE_INTERNAL_GET_DATA_ERROR | This error occurs if getting a data from an internal service fails |
4002 | Failed to update a data in internal service | SERVICE_INTERNAL_UPDATE_ERROR | This error occurs if updating a data in an internal service fails |
4003 | Failed to delete a data in internal service | SERVICE_INTERNAL_DELETE_ERROR | This error occurs if deleting a data from an internal service fails |
4004 | Failed to send data to an internal service | SERVICE_INTERNAL_SEND_DATA_ERROR | This error occurs if sending data to an internal service fails |
4005 | Failed to send a task to an internal service | SERVICE_INTERNAL_SEND_TASK_ERROR | This error occurs if sending a task to an internal service fails |
4100 | Failed to create a data in external service | SERVICE_EXTERNAL_CREATE_DATA_ERROR | This error occurs if creating a data in an external service fails |
4101 | Failed to get data from an external service | SERVICE_EXTERNAL_GET_DATA_ERROR | This error occurs if getting a data from an external service fails |
4102 | Failed to update a data in external service | SERVICE_EXTERNAL_UPDATE_ERROR | This error occurs if updating a data in an external service fails |
4103 | Failed to delete a data in external service | SERVICE_EXTERNAL_DELETE_ERROR | This error occurs if deleting a data from an external service fails |
4104 | Failed to send data to an external service | SERVICE_EXTERNAL_SEND_DATA_ERROR | This error occurs if sending data to an external service fails |
4105 | Failed to send a task to an external service | SERVICE_EXTERNAL_SEND_TASK_ERROR | This error occurs if sending a task to an external service fails |
Quick Start
import { TWE_Error, TWE_Error_Prefix } from "@twe_apollo/error-helper";
export const create = async (data: ITodo): Promise<ITodo> => {
try {
const todo = await todoModel.create(data);
return todo;
} catch (error) {
throw new TWE_Error(TWE_Error_Prefix.DATABASE_INSERT_FAILED, `${error}`);
}
};
Contact
- Murat Demirci - @muratdemirci - muratdemirci@trtworld.com
- Ahmet Can Turan - @ahmtcntrn - ahmetcan.turan@trtworld.com
- Abdullah Obaid - @abdullahOB - abdullah.obaid@trtworld.com