Skip to content

Commit

Permalink
use response message for JS generated errors to differentiate from aj…
Browse files Browse the repository at this point in the history
…ax error/statusText
  • Loading branch information
damianham committed May 17, 2019
1 parent f5d33fd commit a4e5fcd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scaffold/view/src/modules/{{name}}/js/{{name}}.js.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class {{class_name}} extends Resource {
return new Promise(function (resolve, reject) {
// eslint-disable-next-line prefer-promise-reject-errors
reject({
statusText: 'Could not save {{name}}',
message: 'Could not save {{name}}',
responseJSON: {
error: 'Validation failed. [' + errors.map((err) => {
return `Amber::Validators::Error(@param="${err.field}", @value="${err.value}", @message="Field ${err.field} ${err.message}" )`
Expand Down
2 changes: 1 addition & 1 deletion scaffold/view/src/modules/{{name}}/js/{{name}}_edit.js.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class {{class_name}}EditComponent extends React.Component {
store.update('{{name}}', this.state.id, this.state)
.then(this.onBack.bind(this))
.catch((response, statusText, error) => {
store.handleErrors('Update', '{{name}}', error, response.responseJSON)
store.handleErrors('Update', '{{name}}', error || response.message, response.responseJSON)
})
}

Expand Down
2 changes: 1 addition & 1 deletion scaffold/view/src/modules/{{name}}/js/{{name}}_new.js.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class {{class_name}}NewComponent extends React.Component {
let {{name}} = new {{class_name}}(this.state)
{{name}}.save().then(this.onBack.bind(this))
.catch((response, statusText, error) => {
store.handleErrors('Add', '{{name}}', error, response.responseJSON)
store.handleErrors('Add', '{{name}}', error || response.message, response.responseJSON)
});
}

Expand Down
4 changes: 2 additions & 2 deletions scaffold/view/src/modules/{{name}}/js/{{name}}_view.js.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class {{class_name}}ViewComponent extends React.Component {

if (typeof related.catch === 'function') {
related.catch((response, statusText, error) => {
store.handleErrors('Show', 'related', error, response.responseJSON)
store.handleErrors('Show', 'related', error || response.message, response.responseJSON)
})
} else {
// we got an array of records with matching {{name}}_id
Expand All @@ -82,7 +82,7 @@ class {{class_name}}ViewComponent extends React.Component {
}
}).catch((response, statusText, error) => {
console.log('store load resources failed with', error)
store.handleErrors('Query', 'comment', error, response.responseJSON)
store.handleErrors('Query', 'comment', error || response.message, response.responseJSON)
})
*/
}
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: amber_material_kit
version: 1.0.5
version: 1.0.6

authors:
- Damian Hamill <damianham@gmail.com>
Expand Down

0 comments on commit a4e5fcd

Please sign in to comment.