Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/core/plugins/err/error-transformers/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ const errorTransformers = [
ParameterOneOf
]

export default function transformErrors (errors, system) {
export default function transformErrors (errors) {
// Dev note: unimplemented artifact where
// jsSpec: system.specSelectors.specJson().toJS()
// regardless, to be compliant with redux@4, instead of calling the store method here,
// jsSpec should be pass down as an argument,
let inputs = {
jsSpec: system.specSelectors.specJson().toJS()
jsSpec: {}
}

let transformedErrors = reduce(errorTransformers, (result, transformer) => {
Expand Down
14 changes: 7 additions & 7 deletions src/core/plugins/err/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ let DEFAULT_ERROR_STRUCTURE = {
message: "Unknown error"
}

export default function(system) {
export default function() {
return {
[NEW_THROWN_ERR]: (state, { payload }) => {
let error = Object.assign(DEFAULT_ERROR_STRUCTURE, payload, {type: "thrown"})
return state
.update("errors", errors => (errors || List()).push( fromJS( error )) )
.update("errors", errors => transformErrors(errors, system.getSystem()))
.update("errors", errors => transformErrors(errors))
},

[NEW_THROWN_ERR_BATCH]: (state, { payload }) => {
Expand All @@ -34,24 +34,24 @@ export default function(system) {
})
return state
.update("errors", errors => (errors || List()).concat( fromJS( payload )) )
.update("errors", errors => transformErrors(errors, system.getSystem()))
.update("errors", errors => transformErrors(errors))
},

[NEW_SPEC_ERR]: (state, { payload }) => {
let error = fromJS(payload)
error = error.set("type", "spec")
return state
.update("errors", errors => (errors || List()).push( fromJS(error)).sortBy(err => err.get("line")) )
.update("errors", errors => transformErrors(errors, system.getSystem()))
.update("errors", errors => transformErrors(errors))
},

[NEW_SPEC_ERR_BATCH]: (state, { payload }) => {
payload = payload.map(err => {
return fromJS(Object.assign(DEFAULT_ERROR_STRUCTURE, err, { type: "spec" }))
})
return state
.update("errors", errors => (errors || List()).concat( fromJS( payload )) )
.update("errors", errors => transformErrors(errors, system.getSystem()))
.update("errors", errors => (errors || List()).concat(fromJS(payload)))
.update("errors", errors => transformErrors(errors))
},

[NEW_AUTH_ERR]: (state, { payload }) => {
Expand All @@ -60,7 +60,7 @@ export default function(system) {
error = error.set("type", "auth")
return state
.update("errors", errors => (errors || List()).push( fromJS(error)) )
.update("errors", errors => transformErrors(errors, system.getSystem()))
.update("errors", errors => transformErrors(errors))
},

[CLEAR]: (state, { payload }) => {
Expand Down