Skip to content

Commit 1c1c7fc

Browse files
committed
added 422 status error work
1 parent 3aa59fb commit 1c1c7fc

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuex-laravel-resource-api",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"main": "src/Resolver.js",
55
"description": "Vue API library for easy get data from Laravel REST Controller",
66
"dependencies": {

src/errorMessage.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
export default {
2-
500() {
3-
alert('Sorry, some error at the server, please try again later...');
4-
},
5-
401(){
6-
if(confirm('You are no longer authorized. Would you like to log in?'))
7-
window.location.reload();
8-
},
9-
404(){
10-
alert('Seems this feature is still on the developing mode, please try again later...');
11-
},
12-
def(){
13-
alert('Sorry, some unexpected error at the server, please try again later...');
14-
}
15-
}
2+
500() {
3+
alert('Sorry, some error at the server, please try again later...');
4+
},
5+
401() {
6+
if (confirm('You are no longer authorized. Would you like to log in?'))
7+
window.location.reload();
8+
},
9+
404() {
10+
alert('Seems this feature is still on the developing mode, please try again later...');
11+
},
12+
422(axResp){
13+
let d = axResp.response.data || {};
14+
let m = d.message || 'Sorry, some of data sent to the server was invalid.';
15+
let e = '\n\nErrors:';
16+
for(let i in d.errors)
17+
e += '\n'+(Array.isArray(d.errors[i]) && d.errors[i].join(' ') || d.errors[i]);
18+
alert(m+e);
19+
},
20+
def() {
21+
alert('Sorry, some unexpected error at the server, please try again later...');
22+
}
23+
};

0 commit comments

Comments
 (0)