Improved error information to client on both surat-kelulusan and sk-hasil-belajar

This commit is contained in:
Gregorio Chiko Putra
2019-05-16 09:30:36 +07:00
parent 5839165531
commit 30a93871e5
7 changed files with 90 additions and 35 deletions

View File

@@ -2,6 +2,7 @@ import m from "mithril"
var model = {
current: {},
error: {},
fetch: src => {
return m.request({
method: 'get',
@@ -10,6 +11,18 @@ var model = {
})
.then(response => {
model.current = response;
})
.catch(e => {
if (e.code === 0) {
model.error = {
message: e.message,
errors: {
accessLog: ['Terjadi kesalahan saat menghubungkan ke server.']
},
};
}
else
model.error = JSON.parse(e.message);
});
},
create: data => {

View File

@@ -13,10 +13,19 @@ var model = {
})
.then(response => {
model.current = response;
AccessLog.fetch('surat-kelulusan');
AccessLog.fetch(data.src);
})
.catch(e => {
model.error = JSON.parse(e.message);
if (e.code === 0) {
model.error = {
message: e.message,
errors: {
siswa: ['Terjadi kesalahan saat menghubungkan ke server.'],
},
};
}
else
model.error = JSON.parse(e.message);
});
},
}