Skip to content

Commit 4db2edc

Browse files
mathis-mtim-lai
andauthored
feat: verbose Failed to fetch error (#6938)
* feat: verbose Failed to fetch error * refactor: disable console.error in src/core/plugins/spec/actions.js Co-authored-by: Tim Lai <[email protected]>
1 parent b3e08ff commit 4db2edc

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/core/components/live-response.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default class LiveResponse extends React.Component {
6969
return <span className="headerline" key={key}> {key}: {joinedHeaders} </span>
7070
})
7171
const hasHeaders = returnObject.length !== 0
72+
const Markdown = getComponent("Markdown", true)
7273

7374
return (
7475
<div>
@@ -101,9 +102,7 @@ export default class LiveResponse extends React.Component {
101102
</td>
102103
<td className="response-col_description">
103104
{
104-
isError ? <span>
105-
{`${response.get("name")}: ${response.get("message")}`}
106-
</span>
105+
isError ? <Markdown source={`${response.get("name") !== "" ? `${response.get("name")}: ` : ""}${response.get("message")}`}/>
107106
: null
108107
}
109108
{

src/core/plugins/spec/actions.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const requestResolvedSubtree = path => system => {
256256
const isPathAlreadyBatched = requestBatch
257257
.map(arr => arr.join("@@"))
258258
.indexOf(path.join("@@")) > -1
259-
259+
260260
if(isPathAlreadyBatched) {
261261
return
262262
}
@@ -376,9 +376,9 @@ export const executeRequest = (req) =>
376376
let { pathName, method, operation } = req
377377
let { requestInterceptor, responseInterceptor } = getConfigs()
378378

379-
379+
380380
let op = operation.toJS()
381-
381+
382382
// ensure that explicitly-included params are in the request
383383

384384
if (operation && operation.get("parameters")) {
@@ -439,8 +439,8 @@ export const executeRequest = (req) =>
439439
}
440440
)
441441
.filter(
442-
(value, key) => (Array.isArray(value)
443-
? value.length !== 0
442+
(value, key) => (Array.isArray(value)
443+
? value.length !== 0
444444
: !isEmptyValue(value)
445445
) || requestBodyInclusionSetting.get(key)
446446
)
@@ -476,7 +476,11 @@ export const executeRequest = (req) =>
476476
} )
477477
.catch(
478478
err => {
479-
console.error(err)
479+
// console.error(err)
480+
if(err.message === "Failed to fetch") {
481+
err.name = ""
482+
err.message = "**Failed to fetch.** \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be \"http\" or \"https\" for CORS request."
483+
}
480484
specActions.setResponse(req.pathName, req.method, {
481485
error: true, err: serializeError(err)
482486
})

0 commit comments

Comments
 (0)