Skip to content

Commit 7976ac0

Browse files
committed
error handling: send errorType
1 parent 1e54f54 commit 7976ac0

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

lib/Service/Note.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getData(array $exclude = []) : array {
108108
$data['readonly'] = $this->getReadOnly();
109109
}
110110
$data['error'] = false;
111-
$data['errorMessage'] = '';
111+
$data['errorType'] = '';
112112
if (!in_array('content', $exclude)) {
113113
try {
114114
$data['content'] = $this->getContent();
@@ -117,10 +117,11 @@ public function getData(array $exclude = []) : array {
117117
'Could not read content for file: '.$this->file->getPath(),
118118
[ 'exception' => $e ]
119119
);
120-
$message = $this->util->l10n->t('Error').': ('.$this->file->getName().') '.$e->getMessage();
120+
$message = $this->util->l10n->t('Error').': '.get_class($e);
121121
$data['content'] = $message;
122122
$data['error'] = true;
123-
$data['errorMessage'] = $message;
123+
$data['errorType'] = get_class($e);
124+
$data['readonly'] = true;
124125
}
125126
}
126127
return $data;

src/NotesService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export const fetchNotes = () => {
7777
if (response.data.noteIds !== null) {
7878
store.dispatch('updateNotes', { noteIds: response.data.noteIds, notes: response.data.notesData })
7979
}
80-
if (response.data.errorMessage) {
81-
showError(t('notes', 'Error from Nextcloud server: {msg}', { msg: response.data.errorMessage }))
80+
if (response.data.error) {
81+
showError(t('notes', 'Error from Nextcloud server: {msg}', { msg: response.data.errorType }))
8282
} else {
8383
store.commit('setSyncETag', response.headers.etag)
8484
store.commit('setSyncLastModified', response.headers['last-modified'])
@@ -115,7 +115,7 @@ export const fetchNote = noteId => {
115115
console.error(err)
116116
const msg = t('notes', 'Fetching note {id} has failed.', { id: noteId })
117117
store.commit('setNoteAttribute', { noteId, attribute: 'error', value: true })
118-
store.commit('setNoteAttribute', { noteId, attribute: 'errorMessage', value: msg })
118+
store.commit('setNoteAttribute', { noteId, attribute: 'errorType', value: msg })
119119
return store.getter.getNote(noteId)
120120
}
121121
})

src/components/Note.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ export default {
215215
this.preview = false
216216
fetchNote(parseInt(this.noteId))
217217
.then((note) => {
218-
if (note.errorMessage) {
219-
showError(note.errorMessage)
218+
if (note.error) {
219+
showError(t('notes', 'Error from Nextcloud server: {msg}', { msg: note.errorType }))
220220
}
221221
this.startRefreshTimer()
222222
})

src/store/notes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const mutations = {
8484
note.etag = updated.etag
8585
Vue.set(note, 'unsaved', updated.unsaved)
8686
Vue.set(note, 'error', updated.error)
87-
Vue.set(note, 'errorMessage', updated.errorMessage)
87+
Vue.set(note, 'errorType', updated.errorType)
8888
}
8989
} else {
9090
state.notes.push(updated)

0 commit comments

Comments
 (0)