From 87d3cb1916579992249916c2c5d5c6c272c7bf38 Mon Sep 17 00:00:00 2001 From: Paolo Prete Date: Sat, 1 Jun 2024 13:48:17 +0200 Subject: [PATCH] enhancement of handling MIDI input init failure --- lib/python/spontini_server_core.py | 8 ++++++++ lib/webgui/js/midi-functions.js | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/python/spontini_server_core.py b/lib/python/spontini_server_core.py index 49a7a4a..5e16e98 100644 --- a/lib/python/spontini_server_core.py +++ b/lib/python/spontini_server_core.py @@ -834,6 +834,14 @@ def doPostSync(message, request): log(clientInfo + traceback.format_exc(), "E") return sendCompleteResponse("KO", traceback.format_exc().encode("utf8")) + if message['cmd'] == 'LOG': + if not checkMsgStructure(message, 2): + return sendMalformedMsgResponse() + text = message['param1'] + level = message['param2'] + log(clientInfo + text, level) + return sendCompleteResponse("OK", "") + if message['cmd'] == 'EXEC_PLUGIN': if not checkMsgStructure(message, 5): return sendMalformedMsgResponse() diff --git a/lib/webgui/js/midi-functions.js b/lib/webgui/js/midi-functions.js index 8da7d76..0952bd6 100644 --- a/lib/webgui/js/midi-functions.js +++ b/lib/webgui/js/midi-functions.js @@ -226,7 +226,11 @@ function turnOnMidiInputAndListenOnChannel(channel) { WebMidi .enable() .then(onEnabled) - .catch(err => alert(err)); + .catch(err => { + console.error(err) + sendMsgToSpontiniServer({ cmd: 'LOG', param1: "[MIDI input] " + + err.toString(), param2: 'E' }, function(statusTxt, responseTxt) {}) + }); // Function triggered when WebMidi.js is ready function onEnabled() {