All files / src/repositories/errors entity-not-active.error.ts

11.11% Statements 1/9
0% Branches 0/4
0% Functions 0/1
11.11% Lines 1/9

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 28 29 30 31    1x                                                        
import {Entity} from '@loopback/repository';
 
export class EntityNotActiveError<ID, Props extends object = {}> extends Error {
  code: string;
  entityName: string;
  entityId: ID;
 
  constructor(
    entityOrName: typeof Entity | string,
    entityId: ID,
    extraProperties?: Props,
  ) {
    const entityName =
      typeof entityOrName === 'string'
        ? entityOrName
        : entityOrName.modelName || entityOrName.name;
 
    const quotedId = JSON.stringify(entityId);
 
    super(`Entity not active: ${entityName} with id ${quotedId}`);
 
    Error.captureStackTrace(this, this.constructor);
 
    this.code = 'ENTITY_NOT_ACTIVE';
    this.entityName = entityName;
    this.entityId = entityId;
 
    Object.assign(this, extraProperties, {statusCode: 400});
  }
}