mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
25 lines
659 B
TypeScript
25 lines
659 B
TypeScript
import { ValidationError } from 'class-validator';
|
|
|
|
import { eStratumErrorCode } from '../enums/eStratumErrorCode';
|
|
|
|
export class StratumErrorMessage {
|
|
|
|
constructor(
|
|
private id: number = null,
|
|
private errorCode: eStratumErrorCode,
|
|
private errorMessage: string,
|
|
private validationErrors: ValidationError[] = []
|
|
) {
|
|
|
|
}
|
|
|
|
public response(): string {
|
|
|
|
const error = {
|
|
id: this.id,
|
|
result: null,
|
|
error: [this.errorCode, this.errorMessage, this.validationErrors.reduce((pre, cur) => `${pre}, ${cur.value}`, '')]
|
|
}
|
|
return JSON.stringify(error) + '\n';
|
|
}
|
|
} |