mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
stratum error init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user