Add error trace output for /api/refresh and friendly UI display
This commit is contained in:
1 parent
88b9d96af5
commit
283d683b29
1 file changed
+14
-3
@@ -2,6 +2,7 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -314,8 +315,13 @@ def render_dashboard_html(stats):
|
|||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
status.textContent = data.status === 'ok' ? 'Refresh complete' : 'Refresh failed';
|
if (data.status === 'ok') {
|
||||||
document.getElementById('app-result').textContent = JSON.stringify(data.result || data, null, 2);
|
status.textContent = 'Refresh complete';
|
||||||
|
document.getElementById('app-result').textContent = JSON.stringify(data.result, null, 2);
|
||||||
|
} else {
|
||||||
|
status.textContent = 'Refresh failed';
|
||||||
|
document.getElementById('app-result').textContent = JSON.stringify(data, null, 2);
|
||||||
|
}
|
||||||
setTimeout(function() { status.textContent = ''; }, 4500);
|
setTimeout(function() { status.textContent = ''; }, 4500);
|
||||||
setTimeout(function() { location.reload(); }, 1000);
|
setTimeout(function() { location.reload(); }, 1000);
|
||||||
})
|
})
|
||||||
@@ -434,7 +440,12 @@ def _build_handler(stats_supplier):
|
|||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
response = {"status": "error", "message": str(exc)}
|
trace = traceback.format_exc()
|
||||||
|
response = {
|
||||||
|
"status": "error",
|
||||||
|
"message": str(exc),
|
||||||
|
"trace": trace,
|
||||||
|
}
|
||||||
content = json.dumps(response, default=str).encode("utf-8")
|
content = json.dumps(response, default=str).encode("utf-8")
|
||||||
self.send_response(500)
|
self.send_response(500)
|
||||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
self.send_header("Content-Type", "application/json; charset=utf-8")
|
||||||
|
|||||||
Reference in new issue
Block a user