- Updated error handling in videoProcessor.js, videoProcessorWebGL.js, videoSync.js, viewerInstanceManager.js, and various utility files to log caught exceptions using console.debug. - Introduced a new script to automate the replacement of silent catch blocks with logging statements. - Enhanced safety checks in the database schema and transaction manager to prevent SQL injection vulnerabilities. - Added regex patterns for validating column definitions and executable names in the ExifTool adapter. - Improved error handling in health and filesystem routes to ensure better feedback on invalid inputs. - Added tests to cover new error handling and validation logic.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { APP_CONFIG } from "../app/config.js";
|
|
|
|
export const noop = () => {};
|
|
|
|
function _debugEnabled(flag) {
|
|
try {
|
|
return Boolean(APP_CONFIG?.[flag]);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function _warn(label, err) {
|
|
try {
|
|
console.warn(`[Majoor] ${label}`, err);
|
|
} catch (e) { console.debug?.(e); }
|
|
}
|
|
|
|
export function safeCall(fn, label = "safeCall") {
|
|
try {
|
|
return fn?.();
|
|
} catch (err) {
|
|
if (_debugEnabled("DEBUG_SAFE_CALL")) _warn(label, err);
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
export function safeAddListener(target, event, handler, options, label = "safeAddListener") {
|
|
try {
|
|
target?.addEventListener?.(event, handler, options);
|
|
return () => {
|
|
try {
|
|
target?.removeEventListener?.(event, handler, options);
|
|
} catch (err) {
|
|
if (_debugEnabled("DEBUG_SAFE_LISTENERS")) _warn(`${label}:remove:${String(event || "")}`, err);
|
|
}
|
|
};
|
|
} catch (err) {
|
|
if (_debugEnabled("DEBUG_SAFE_LISTENERS")) _warn(`${label}:add:${String(event || "")}`, err);
|
|
return noop;
|
|
}
|
|
}
|