fix(common): set name of httpexception as class name

Added a method to set name property of exception object equal to class name which currently is always Error. Updated tests.

Closes #5809
This commit is contained in:
Karan Gupta
2020-12-04 12:06:09 +05:30
parent 26609840a4
commit 66b1a6a420

View File

@@ -62,7 +62,7 @@ describe('HttpException', () => {
it('should be serializable', () => {
const message = 'Some Error';
const error = new HttpException(message, 400);
expect(`${error}`).to.be.eql(`Error: ${message}`);
expect(`${error}`).to.be.eql(`HttpException: ${message}`);
});
describe('when "response" is an object', () => {
@@ -71,8 +71,10 @@ describe('HttpException', () => {
const error = new HttpException(obj, 400);
const badRequestError = new BadRequestException(obj);
expect(`${error}`).to.be.eql(`Error: Http Exception`);
expect(`${badRequestError}`).to.be.eql(`Error: Bad Request Exception`);
expect(`${error}`).to.be.eql(`HttpException: Http Exception`);
expect(`${badRequestError}`).to.be.eql(
`BadRequestException: Bad Request Exception`,
);
expect(`${error}`.includes('[object Object]')).to.not.be.true;
expect(`${badRequestError}`.includes('[object Object]')).to.not.be.true;
});
@@ -80,7 +82,7 @@ describe('HttpException', () => {
it('should concat strings', () => {
const test = 'test message';
const error = new HttpException(test, 400);
expect(`${error}`).to.be.eql(`Error: ${test}`);
expect(`${error}`).to.be.eql(`HttpException: ${test}`);
expect(`${error}`.includes('[object Object]')).to.not.be.true;
});
});