null checking error response model

This commit is contained in:
Kyle Spearrin 2019-03-06 21:37:40 -05:00
parent 82f8f2b85e
commit e9cbf7b7df
2 changed files with 10 additions and 6 deletions

View File

@ -9,8 +9,10 @@ export abstract class BaseResponse {
if (propertyName == null || propertyName === '') {
throw new Error('propertyName must not be null/empty.');
}
if (response == null) {
if (response == null && this.response != null) {
response = this.response;
} else {
return null;
}
if (!exactName && response[propertyName] === undefined) {
let otherCasePropertyName: string = null;

View File

@ -8,12 +8,14 @@ export class ErrorResponse extends BaseResponse {
constructor(response: any, status: number, identityResponse?: boolean) {
super(response);
let errorModel = null;
if (response != null) {
const responseErrorModel = this.getResponseProperty('ErrorModel');
if (responseErrorModel && identityResponse && response) {
if (responseErrorModel && identityResponse) {
errorModel = responseErrorModel;
} else if (response) {
} else {
errorModel = response;
}
}
if (errorModel) {
this.message = this.getResponseProperty('Message', errorModel);