Skip to content

Commit 9870126

Browse files
committed
Address styling concerns
1 parent 8a80de3 commit 9870126

6 files changed

Lines changed: 18 additions & 16 deletions

File tree

packages/common/exceptions/http.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class HttpException extends Error {
3131
return this.status;
3232
}
3333

34-
private getErrorString(target: string | object) {
34+
private getErrorString(target: string | object): string{
3535
if (typeof target === 'string') {
3636
return target;
3737
}

packages/common/test/exceptions/http.exception.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,28 @@ describe('HttpException', () => {
4545
});
4646
});
4747

48-
it('Should inherit from error', () => {
48+
it('should inherit from error', () => {
4949
const error = new HttpException('', 400);
5050
expect(error instanceof Error).to.be.true;
5151
});
5252

53-
it('Should be serializable', () => {
53+
it('should be serializable', () => {
5454
const message = 'Some Error';
5555
const error = new HttpException(message, 400);
5656
expect(`${error}`).to.be.eql(`Error: ${message}`);
5757
});
5858

59-
it('Should serialize objects', () => {
60-
const obj = { foo: 'bar' };
61-
const error = new HttpException(obj, 400);
62-
expect(`${error}`).to.be.eql(`Error: ${JSON.stringify(obj)}`);
63-
expect(`${error}`.includes('[object Object]')).to.not.be.true;
64-
});
59+
describe('when "message" is an object', () => {
60+
it('should serialize an object', () => {
61+
const obj = { foo: 'bar' };
62+
const error = new HttpException(obj, 400);
63+
expect(`${error}`).to.be.eql(`Error: ${JSON.stringify(obj)}`);
64+
expect(`${error}`.includes('[object Object]')).to.not.be.true;
65+
});
6566

66-
it('Should serialize sub errors', () => {
67-
const error = new NotFoundException();
68-
expect(`${error}`.includes('Not Found')).to.be.true;
67+
it('should serialize sub errors', () => {
68+
const error = new NotFoundException();
69+
expect(`${error}`.includes('Not Found')).to.be.true;
70+
});
6971
});
7072
});

packages/microservices/exceptions/rpc-exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class RpcException extends Error {
99
return this.error;
1010
}
1111

12-
private getErrorString(target) {
12+
private getErrorString(target: string | object): string {
1313
if (typeof target === 'string') {
1414
return target;
1515
}

packages/microservices/test/exceptions/rpc-exception.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('RpcException', () => {
1212
expect(instance.getError()).to.be.eql(error);
1313
});
1414

15-
it('Should serialize', () => {
15+
it('should serialize', () => {
1616
expect(`${instance}`.includes(error)).to.be.true;
1717
const obj = {foo: 'bar'};
1818
expect(`${new RpcException(obj)}`.includes(JSON.stringify(obj))).to.be.true;

packages/websockets/errors/ws-exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class WsException extends Error {
1010
return this.error;
1111
}
1212

13-
private getErrorString(target) {
13+
private getErrorString(target: string | object): string {
1414
if (typeof target === 'string') {
1515
return target;
1616
}

packages/websockets/test/exceptions/ws-exception.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('WsException', () => {
1212
expect(instance.getError()).to.be.eql(error);
1313
});
1414

15-
it('Should serialize', () => {
15+
it('should serialize', () => {
1616
expect(`${instance}`.includes(error)).to.be.true;
1717
const obj = {foo: 'bar'};
1818
expect(`${new WsException(obj)}`.includes(JSON.stringify(obj))).to.be.true;

0 commit comments

Comments
 (0)