refactor(): adjust to the codebase guidelines

This commit is contained in:
Kamil Myśliwiec
2019-07-09 15:13:26 +02:00
parent 9166d40ade
commit 41e4e853f6
4 changed files with 30 additions and 35 deletions

View File

@@ -1,3 +1,5 @@
import { isString } from '@nestjs/common/utils/shared.utils';
export class RpcException extends Error {
public readonly message: any;
constructor(private readonly error: string | object) {
@@ -9,17 +11,12 @@ export class RpcException extends Error {
return this.error;
}
private getErrorString(target: string | object): string {
if (typeof target === 'string') {
return target;
}
return JSON.stringify(target);
}
public toString(): string {
const message = this.getErrorString(this.message);
return `Error: ${message}`;
}
private getErrorString(target: string | object): string {
return isString(target) ? target : JSON.stringify(target);
}
}