trusona/trusona-server-sdk-js

View on GitHub
src/resources/handler/UserErrorHandler.js

Summary

Maintainability
A
1 hr
Test Coverage
F
57%
const GenericErrorHandler = require('./GenericErrorHandler')
const UserNotFoundError = require('../error/UserNotFoundError')

const USER_NOT_FOUND_MESSAGE = 'The user you are attempting to deactivate does not exist or is already inactive.'

class UserErrorHandler extends GenericErrorHandler {

  static handleError(response) {
    if (response.statusCode === 404) {
      throw new UserNotFoundError(this.formatMessage(response.statusCode, USER_NOT_FOUND_MESSAGE))
    }
    return super.handleError(response)
  }

}

module.exports = UserErrorHandler