stratum error init

This commit is contained in:
Ben Wilson
2023-07-01 06:51:37 -04:00
parent 0c80b084ee
commit b147eff49a
3 changed files with 45 additions and 1 deletions
@@ -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');
}
}