add ids to data when erroring with multipleResults

This commit is contained in:
Kyle Spearrin 2019-10-21 13:51:48 -04:00
parent b3d1e9d233
commit 8ab36db5c6
2 changed files with 4 additions and 3 deletions

View File

@ -69,7 +69,7 @@ export abstract class BaseProgram {
} }
} }
protected getMessage(response: Response) { protected getMessage(response: Response): string {
const message = (response.data as MessageResponse); const message = (response.data as MessageResponse);
if (process.env.BW_RAW === 'true') { if (process.env.BW_RAW === 'true') {
return message.raw; return message.raw;

View File

@ -1,7 +1,7 @@
import { BaseResponse } from './response/baseResponse'; import { BaseResponse } from './response/baseResponse';
export class Response { export class Response {
static error(error: any): Response { static error(error: any, data?: any): Response {
const res = new Response(); const res = new Response();
res.success = false; res.success = false;
if (typeof (error) === 'string') { if (typeof (error) === 'string') {
@ -9,6 +9,7 @@ export class Response {
} else { } else {
res.message = error.message != null ? error.message : error.toString(); res.message = error.message != null ? error.message : error.toString();
} }
res.data = data;
return res; return res;
} }
@ -26,7 +27,7 @@ export class Response {
ids.forEach((id) => { ids.forEach((id) => {
msg += '\n' + id; msg += '\n' + id;
}); });
return Response.error(msg); return Response.error(msg, ids);
} }
static success(data?: BaseResponse): Response { static success(data?: BaseResponse): Response {