feat: display last error when definition/config load fails
Contains a breaking internal API change to `errActions.newThrownErr`, which will require a MINOR version bump. Swagger-Editor does not depend on the old usage style.
This commit is contained in:
committed by
kyle
parent
a8f204181e
commit
bd41b736a8
@@ -26,7 +26,7 @@ export default function downloadUrlPlugin (toolbox) {
|
|||||||
function next(res) {
|
function next(res) {
|
||||||
if(res instanceof Error || res.status >= 400) {
|
if(res instanceof Error || res.status >= 400) {
|
||||||
specActions.updateLoadingStatus("failed")
|
specActions.updateLoadingStatus("failed")
|
||||||
return errActions.newThrownErr( new Error(res.statusText + " " + url) )
|
return errActions.newThrownErr( new Error((res.message || res.statusText) + " " + url) )
|
||||||
}
|
}
|
||||||
specActions.updateLoadingStatus("success")
|
specActions.updateLoadingStatus("success")
|
||||||
specActions.updateSpec(res.text)
|
specActions.updateSpec(res.text)
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ export const NEW_SPEC_ERR_BATCH = "err_new_spec_err_batch"
|
|||||||
export const NEW_AUTH_ERR = "err_new_auth_err"
|
export const NEW_AUTH_ERR = "err_new_auth_err"
|
||||||
export const CLEAR = "err_clear"
|
export const CLEAR = "err_clear"
|
||||||
|
|
||||||
export function newThrownErr(err, action) {
|
export function newThrownErr(err) {
|
||||||
return {
|
return {
|
||||||
type: NEW_THROWN_ERR,
|
type: NEW_THROWN_ERR,
|
||||||
payload: { action, error: serializeError(err) }
|
payload: serializeError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ function createStoreWithMiddleware(rootReducer, initialState, getSystem) {
|
|||||||
// createLogger( {
|
// createLogger( {
|
||||||
// stateTransformer: state => state && state.toJS()
|
// stateTransformer: state => state && state.toJS()
|
||||||
// } ),
|
// } ),
|
||||||
// errorLog(getSystem), Need to properly handle errors that occur during a render. Ie: let them be...
|
|
||||||
systemThunkMiddleware( getSystem )
|
systemThunkMiddleware( getSystem )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -126,15 +126,6 @@ export function systemThunkMiddleware(getSystem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const errorLog = getSystem => () => next => action => {
|
|
||||||
try{
|
|
||||||
next( action )
|
|
||||||
}
|
|
||||||
catch( e ) {
|
|
||||||
getSystem().errActions.newThrownErr( e, action )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function defaultStatusCode ( responses ) {
|
export function defaultStatusCode ( responses ) {
|
||||||
let codes = responses.keySeq()
|
let codes = responses.keySeq()
|
||||||
return codes.contains(DEFAULT_REPONSE_KEY) ? DEFAULT_REPONSE_KEY : codes.filter( key => (key+"")[0] === "2").sort().first()
|
return codes.contains(DEFAULT_REPONSE_KEY) ? DEFAULT_REPONSE_KEY : codes.filter( key => (key+"")[0] === "2").sort().first()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default class StandaloneLayout extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { getComponent, specSelectors } = this.props
|
let { getComponent, specSelectors, errSelectors } = this.props
|
||||||
|
|
||||||
let Container = getComponent("Container")
|
let Container = getComponent("Container")
|
||||||
let Row = getComponent("Row")
|
let Row = getComponent("Row")
|
||||||
@@ -27,6 +27,8 @@ export default class StandaloneLayout extends React.Component {
|
|||||||
const OnlineValidatorBadge = getComponent("onlineValidatorBadge", true)
|
const OnlineValidatorBadge = getComponent("onlineValidatorBadge", true)
|
||||||
|
|
||||||
const loadingStatus = specSelectors.loadingStatus()
|
const loadingStatus = specSelectors.loadingStatus()
|
||||||
|
const lastErr = errSelectors.lastError()
|
||||||
|
const lastErrMsg = lastErr ? lastErr.get("message") : ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
@@ -43,12 +45,16 @@ export default class StandaloneLayout extends React.Component {
|
|||||||
<div className="info">
|
<div className="info">
|
||||||
<div className="loading-container">
|
<div className="loading-container">
|
||||||
<h4 className="title">Failed to load API definition.</h4>
|
<h4 className="title">Failed to load API definition.</h4>
|
||||||
</div>
|
<p>{lastErrMsg}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{ loadingStatus === "failedConfig" &&
|
{ loadingStatus === "failedConfig" &&
|
||||||
<div className="info" style={{ maxWidth: "880px", marginLeft: "auto", marginRight: "auto", textAlign: "center" }}>
|
<div className="info" style={{ maxWidth: "880px", marginLeft: "auto", marginRight: "auto", textAlign: "center" }}>
|
||||||
<h4 className="title">Failed to load remote configuration.</h4>
|
<div className="loading-container">
|
||||||
|
<h4 className="title">Failed to load remote configuration.</h4>
|
||||||
|
<p>{lastErrMsg}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{ !loadingStatus || loadingStatus === "success" && <BaseLayout /> }
|
{ !loadingStatus || loadingStatus === "success" && <BaseLayout /> }
|
||||||
|
|||||||
@@ -657,6 +657,8 @@
|
|||||||
min-height: 1px;
|
min-height: 1px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.loading
|
.loading
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user