mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
refactor(): adjust to the codebase guidelines
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user