Skip to content

Commit

Permalink
Improve the error display on the web based updater
Browse files Browse the repository at this point in the history
Wraps the plain response body in a <details> tag

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Sep 15, 2020
1 parent 1cd82f2 commit 3d1d1be
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,10 @@ public function logVersion() {
margin: 0 auto;
}

pre {
word-wrap: break-word;
}

</style>
</head>
<body>
Expand Down Expand Up @@ -1879,7 +1883,8 @@ function performStep(number, callback) {
// it seems that this is not a JSON object
var response = {
processed: false,
response: 'Parsing response failed. ' + httpRequest.responseText
response: 'Parsing response failed.',
detailedResponseText: httpRequest.responseText,
};
callback(response);
} else {
Expand Down Expand Up @@ -1908,6 +1913,8 @@ function performStep(number, callback) {
var text = '';
if (typeof response['response'] === 'string') {
text = escapeHTML(response['response']);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response['detailedResponseText']) + '</code></pre></details>';
} else {
text = 'The following extra files have been found:<ul>';
response['response'].forEach(function(file) {
Expand All @@ -1929,6 +1936,8 @@ function performStep(number, callback) {
var text = '';
if (typeof response['response'] === 'string') {
text = escapeHTML(response['response']);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response['detailedResponseText']) + '</code></pre></details>';
} else {
text = 'The following places can not be written to:<ul>';
response['response'].forEach(function(file) {
Expand All @@ -1948,7 +1957,10 @@ function performStep(number, callback) {
errorStep('step-backup', 3);

if(response.response) {
addStepText('step-backup', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-backup', text);
}
}
},
Expand All @@ -1961,7 +1973,10 @@ function performStep(number, callback) {
errorStep('step-download', 4);

if(response.response) {
addStepText('step-download', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-download', text);
}
}
},
Expand All @@ -1974,7 +1989,10 @@ function performStep(number, callback) {
errorStep('step-verify-integrity', 5);

if(response.response) {
addStepText('step-verify-integrity', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-verify-integrity', text);
}
}
},
Expand All @@ -1987,7 +2005,10 @@ function performStep(number, callback) {
errorStep('step-extract', 6);

if(response.response) {
addStepText('step-extract', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-extract', text);
}
}
},
Expand All @@ -2000,7 +2021,10 @@ function performStep(number, callback) {
errorStep('step-enable-maintenance', 7);

if(response.response) {
addStepText('step-enable-maintenance', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-enable-maintenance', text);
}
}
},
Expand All @@ -2013,7 +2037,10 @@ function performStep(number, callback) {
errorStep('step-entrypoints', 8);

if(response.response) {
addStepText('step-entrypoints', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-entrypoints', text);
}
}
},
Expand All @@ -2026,7 +2053,10 @@ function performStep(number, callback) {
errorStep('step-delete', 9);

if(response.response) {
addStepText('step-delete', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-delete', text);
}
}
},
Expand All @@ -2043,7 +2073,10 @@ function performStep(number, callback) {
errorStep('step-move', 10);

if(response.response) {
addStepText('step-move', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-move', text);
}
}
},
Expand All @@ -2056,7 +2089,10 @@ function performStep(number, callback) {
errorStep('step-maintenance-mode', 11);

if(response.response) {
addStepText('step-maintenance-mode', escapeHTML(response.response));
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-maintenance-mode', text);
}
}
},
Expand Down

0 comments on commit 3d1d1be

Please sign in to comment.