All files / app/errors unauthorized-error.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x                               146x 92x   54x     146x       1x  
import {RestError} from './rest-error';
 
/**
 * Error if the user isn't authorized for the resources he/she requested.
 *
 * Or if the send token is not valid.
 */
class UnauthorizedError extends RestError {
  /**
   * Creates an instance of this class.
   * @param message - The message of the error.
   *                  If none is provided the following default message is used:
   *                  `You're not authorized to access the resource`
   */
  constructor(message?: string) {
    let _message;
    if (message !== undefined) {
      _message = message;
    } else {
      _message = 'You\'re not authorized to access the resource';
    }
 
    super(401, _message);
  }
}
 
export default UnauthorizedError;