Skip to content

Commit 5fec72b

Browse files
committed
add catch error
Signed-off-by: zhangtianli2006 <49156174+zhangtianli2006@users.noreply.github.com>
1 parent 60d2e83 commit 5fec72b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/components/problem/edit.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ export default {
139139
this.contentLoading = false;
140140
})
141141
.catch(err => {
142-
this.$SegmentMessage.error(this, 'Problem loading error');
143-
console.log(err);
142+
if (err.request.status === 404) {
143+
this.$SegmentMessage.error(this, 'Problem not found');
144+
} else if (err.request.status === 403) {
145+
this.$SegmentMessage.error(this, 'Permission denied');
146+
} else {
147+
this.$SegmentMessage.error(this, 'Unkown error');
148+
}
144149
});
145150
},
146151
back() {

src/components/user/edit.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ export default {
129129
this.isActive = data.is_active;
130130
this.lang = String(data.lang);
131131
}
132+
})
133+
.catch(err => {
134+
if (err.request.status === 404) {
135+
this.$SegmentMessage.error(this, 'User not found');
136+
} else if (err.request.status === 403) {
137+
this.$SegmentMessage.error(this, 'Permission denied');
138+
} else {
139+
this.$SegmentMessage.error(this, 'Unkown error');
140+
}
132141
});
133142
},
134143
submit() {
@@ -154,6 +163,15 @@ export default {
154163
lang: this.lang
155164
});
156165
}
166+
})
167+
.catch(err => {
168+
if (err.request.status === 404) {
169+
this.$SegmentMessage.error(this, 'User not found');
170+
} else if (err.request.status === 403) {
171+
this.$SegmentMessage.error(this, 'Permission denied');
172+
} else {
173+
this.$SegmentMessage.error(this, 'Unkown error');
174+
}
157175
});
158176
}
159177
},

0 commit comments

Comments
 (0)