File tree Expand file tree Collapse file tree
view/base/templates/script Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,13 +100,18 @@ if ($interval < 10) {
100100 headers: this.getPostHeaders(),
101101 body: JSON.stringify(this.buildBody(requests))
102102 })
103- .then(response => {
103+ .then(async response => {
104+ const body = await response.text();
104105 if (response.ok) {
105- return response.text()
106+ return body;
106107 }
107108
108109 LokiComponentsLogger.error('Fetch error', response);
109- throw new Error(response.statusText);
110+
111+ const error = new Error(response.statusText);
112+ error.status = response.status;
113+ error.body = body;
114+ throw error;
110115 })
111116 .then(html => {
112117 try {
@@ -122,7 +127,12 @@ if ($interval < 10) {
122127 this.afterPostSuccess(incomingRequests);
123128 })
124129 .catch(error => {
125- Alpine.store('Message').addErrorMessage(error);
130+ let errorMessage = error.name;
131+ if (error.body) {
132+ errorMessage = error.body.split(/\r?\n/)[0];
133+ }
134+
135+ Alpine.store('Message').addErrorMessage(errorMessage);
126136 })
127137 .finally(() => {
128138 this.afterPostFinally(incomingRequests);
You can’t perform that action at this time.
0 commit comments