mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
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:
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user