Add Ollama/organize logging to debug 403 filing failures

- Log raw Ollama HTTP body on non-2xx responses

- Log JSON extraction failures with raw content

- Log organizeWatcher tick errors instead of swallowing them

Signed-off-by: William Mantly <wmantly@gmail.com>
This commit is contained in:
2026-07-20 11:55:41 -04:00
parent e9a376925d
commit 40a39b2d14
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -7,8 +7,16 @@ function extractJSON(content){
let text = String(content).replace(/```json/gi, '').replace(/```/g, '').trim(); let text = String(content).replace(/```json/gi, '').replace(/```/g, '').trim();
let start = text.indexOf('{'); let start = text.indexOf('{');
let end = text.lastIndexOf('}'); let end = text.lastIndexOf('}');
if(start === -1 || end === -1) throw new Error('No JSON in model response'); if(start === -1 || end === -1){
console.error('extractJSON: no JSON object found in:', content);
throw new Error('No JSON in model response');
}
try{
return JSON.parse(text.slice(start, end + 1)); return JSON.parse(text.slice(start, end + 1));
}catch(error){
console.error('extractJSON: parse failed. extracted:', text.slice(start, end + 1));
throw error;
}
} }
// One-shot JSON chat against the Ollama cloud model. // One-shot JSON chat against the Ollama cloud model.
@@ -30,6 +38,8 @@ async function chatJSON(system, user){
}), }),
}); });
if(!res.ok){ if(!res.ok){
let body = await res.text().catch(() => '');
console.error(`Ollama chat failed (${res.status}):`, body.slice(0, 500));
let error = new Error('OllamaError'); let error = new Error('OllamaError');
error.message = `Ollama chat failed( ${res.status})`; error.message = `Ollama chat failed( ${res.status})`;
error.status = 502; error.status = 502;
+2
View File
@@ -31,6 +31,8 @@ async function tick(){
} }
}catch(error){ }catch(error){
// Transmission down / transient — just try again next tick. // Transmission down / transient — just try again next tick.
console.error('organizeWatcher tick failed:', error.name, error.message);
if(error.stack) console.error(error.stack);
}finally{ }finally{
lock = false; lock = false;
} }