errorhandling

6.2.0 • Public • Published

Error Handling Module

Common module to create error response object at server side

List of all constant error codes

  • Sequelize error code series starts from 1001
  • Cassandra error code series starts from 2001
  • Unknown error code series starts from 3001
  • Business logic error code series starts from 5001
  • Internal error code series starts from 7001
1) constants.SUCCESS
2) constants.CREATED
3) constants.SEQUELIZE_DATABASE_ERROR
4) constants.SEQUELIZE_VALIDATION_ERROR
5) constants.CASSANDRA_DATABASE_ERROR
6) constants.CASSANDRA_VALIDATION_ERROR
7) constants.UNDEFINED_DATABASE_ERROR
8) constants.UNDEFINED_ERROR
9) constants.USER_DUPLICATION_ERROR
10) constants.INVALID_JSON_OBJECT
11) constants.USER_NOT_FOUND
12) constants.COMPARE_PASSWORD_ERROR
13) constants.PASSWORD_NOT_MATCH
14) constants.VALID_CREDENTIALS
15) constants.EMAIL_ALREADY_EXIST
16) constants.INVALID_QUERY_PARAMETERS
17) constants.ERROR_OCCURED_IN_GETTING_USER_LIST
18) constants.UPDATE_DATA_ERROR
19) constants.DELETE_DATA_ERROR
20) constants.KEY_ALREADY_USED
21) constants.ERROR_OCCURED_IN_GETTING_MASTER_LIST
22) constants.SEQUELIZE_FOREIGN_KEY_CONSTRAINT_ERROR
23) constants.ERROR_OCCURED_IN_GETTING_ECG_DATA

Sample response

1) Success Response
{
  "code": "SS-200",
  "message": "Success",
  "data": [
    {
      "id": "204adf30-f444-11e6-bf17-574185f61676",
      "account": 1,      
      "ticket_id": null,
      "timestamp": "1486665020",
      "sensor_uuid": "1234",
      "ecgdata_status": null,
      "ticket_number": null,
      "patient_id": null
    }
  ]
}
2) Error Response
{
  "code": "US-1002",
  "message": "Sequelize validation failed",
  "error": {
    "name": "SequelizeValidationError",
    "message": "notNull Violation: first_name cannot be null",
    "errors": [
      {
        "message": "first_name cannot be null",
        "type": "notNull Violation",
        "path": "first_name",
        "value": null
      }
    ]
  }
}

Commands to pubish npm module

1) Login-
    npm login    
3) Publish npm module-
    npm publish
4) Update existing npm module with new version-
    npm version [patch/minor/major]   
    npm publish      
5) Update readme file for npm module-
    npm publish --update-readme
5) Update package.json of app with new version-
    npm update --save   

Readme

Keywords

none

Package Sidebar

Install

npm i errorhandling

Weekly Downloads

2

Version

6.2.0

License

ISC

Last publish

Collaborators

  • shiwani