Isolate BodyFormatter exceptions
Summary: If one throws an exception, we'd skip all the other ones. I don't think that's the behaviour we want. Reviewed By: passy Differential Revision: D12958926 fbshipit-source-id: dd82b750197b6fc1380496be4147fe63454d39da
This commit is contained in:
committed by
Facebook Github Bot
parent
a56d7d5d72
commit
bdc3abacbd
@@ -336,24 +336,23 @@ class RequestBodyInspector extends Component<{
|
|||||||
const {request, formattedText} = this.props;
|
const {request, formattedText} = this.props;
|
||||||
const bodyFormatters = formattedText ? TextBodyFormatters : BodyFormatters;
|
const bodyFormatters = formattedText ? TextBodyFormatters : BodyFormatters;
|
||||||
let component;
|
let component;
|
||||||
try {
|
|
||||||
for (const formatter of bodyFormatters) {
|
for (const formatter of bodyFormatters) {
|
||||||
if (formatter.formatRequest) {
|
if (formatter.formatRequest) {
|
||||||
|
try {
|
||||||
component = formatter.formatRequest(request);
|
component = formatter.formatRequest(request);
|
||||||
if (component) {
|
if (component) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(
|
||||||
|
'BodyFormatter exception from ' + formatter.constructor.name,
|
||||||
|
e.getMessage(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (component == null && request.data != null) {
|
|
||||||
component = <Text>{decodeBody(request)}</Text>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component == null) {
|
component = component || <Text>{decodeBody(request)}</Text>;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <BodyContainer>{component}</BodyContainer>;
|
return <BodyContainer>{component}</BodyContainer>;
|
||||||
}
|
}
|
||||||
@@ -368,16 +367,21 @@ class ResponseBodyInspector extends Component<{
|
|||||||
const {request, response, formattedText} = this.props;
|
const {request, response, formattedText} = this.props;
|
||||||
const bodyFormatters = formattedText ? TextBodyFormatters : BodyFormatters;
|
const bodyFormatters = formattedText ? TextBodyFormatters : BodyFormatters;
|
||||||
let component;
|
let component;
|
||||||
try {
|
|
||||||
for (const formatter of bodyFormatters) {
|
for (const formatter of bodyFormatters) {
|
||||||
if (formatter.formatResponse) {
|
if (formatter.formatResponse) {
|
||||||
|
try {
|
||||||
component = formatter.formatResponse(request, response);
|
component = formatter.formatResponse(request, response);
|
||||||
if (component) {
|
if (component) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(
|
||||||
|
'BodyFormatter exception from ' + formatter.constructor.name,
|
||||||
|
e.getMessage(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
component = component || <Text>{decodeBody(response)}</Text>;
|
component = component || <Text>{decodeBody(response)}</Text>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user