Skip to content

Commit 8d1583c

Browse files
committed
Refactor error logging for disconnect reasons to remove redundant messages
1 parent 36d29da commit 8d1583c

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

content/wardrive.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,8 +2490,7 @@ async function requestAuth(reason) {
24902490
// Check if server returned a known error code
24912491
if (data && data.reason && REASON_MESSAGES[data.reason]) {
24922492
debugLog(`[AUTH] Known error code: ${data.reason} - ${data.message || REASON_MESSAGES[data.reason]}`);
2493-
// Don't add generic error log entry - the specific error will be shown in disconnect UI
2494-
debugError(`[AUTH] API returned error status ${response.status}: ${serverMsg}`);
2493+
// Don't add error log entry - the specific error will be shown in disconnect UI
24952494
if (reason === "connect") {
24962495
state.disconnectReason = data.reason;
24972496
return false;
@@ -6063,70 +6062,70 @@ async function connect() {
60636062
if (state.disconnectReason && REASON_MESSAGES[state.disconnectReason]) {
60646063
debugLog(`[BLE] Branch: known reason code (${state.disconnectReason})`);
60656064
const errorMsg = REASON_MESSAGES[state.disconnectReason];
6066-
addErrorLogEntry(`Disconnected: ${errorMsg} (reason: ${state.disconnectReason})`, "CONNECTION");
6065+
addErrorLogEntry(`${errorMsg} (reason: ${state.disconnectReason})`, "CONNECTION");
60676066
setDynamicStatus(errorMsg, STATUS_COLORS.error, true);
60686067
debugLog(`[BLE] Setting terminal status for reason: ${state.disconnectReason}`);
60696068
} else if (state.disconnectReason === "capacity_full") {
60706069
debugLog("[BLE] Branch: capacity_full");
6071-
addErrorLogEntry("Disconnected: MeshMapper server at capacity - too many active connections", "CONNECTION");
6070+
addErrorLogEntry("MeshMapper server at capacity - too many active connections", "CONNECTION");
60726071
setDynamicStatus("MeshMapper at capacity", STATUS_COLORS.error, true);
60736072
debugLog("[BLE] Setting terminal status for capacity full");
60746073
} else if (state.disconnectReason === "app_down") {
60756074
debugLog("[BLE] Branch: app_down");
6076-
addErrorLogEntry("Disconnected: MeshMapper server unavailable - check service status", "CONNECTION");
6075+
addErrorLogEntry("MeshMapper server unavailable - check service status", "CONNECTION");
60776076
setDynamicStatus("MeshMapper unavailable", STATUS_COLORS.error, true);
60786077
debugLog("[BLE] Setting terminal status for app down");
60796078
} else if (state.disconnectReason === "slot_revoked") {
60806079
debugLog("[BLE] Branch: slot_revoked");
6081-
addErrorLogEntry("Disconnected: Wardriving slot revoked by server - exceeded limits or policy violation", "CONNECTION");
6080+
addErrorLogEntry("Wardriving slot revoked by server - exceeded limits or policy violation", "CONNECTION");
60826081
setDynamicStatus("MeshMapper slot revoked", STATUS_COLORS.error, true);
60836082
debugLog("[BLE] Setting terminal status for slot revocation");
60846083
} else if (state.disconnectReason === "session_id_error") {
60856084
debugLog("[BLE] Branch: session_id_error");
6086-
addErrorLogEntry("Disconnected: Session ID error - failed to establish valid wardrive session", "CONNECTION");
6085+
addErrorLogEntry("Session ID error - failed to establish valid wardrive session", "CONNECTION");
60876086
setDynamicStatus("Session error - reconnect", STATUS_COLORS.error, true);
60886087
debugLog("[BLE] Setting terminal status for session_id error");
60896088
} else if (state.disconnectReason === "public_key_error") {
60906089
debugLog("[BLE] Branch: public_key_error");
6091-
addErrorLogEntry("Disconnected: Device public key error - invalid or missing key from companion", "CONNECTION");
6090+
addErrorLogEntry("Device public key error - invalid or missing key from companion", "CONNECTION");
60926091
setDynamicStatus("Device key error - reconnect", STATUS_COLORS.error, true);
60936092
debugLog("[BLE] Setting terminal status for public key error");
60946093
} else if (state.disconnectReason === "zone_disabled") {
60956094
debugLog("[GEO AUTH] Branch: zone_disabled");
6096-
addErrorLogEntry("Disconnected: Zone disabled - wardriving not allowed in this area", "CONNECTION");
6095+
addErrorLogEntry("Zone disabled - wardriving not allowed in this area", "CONNECTION");
60976096
setDynamicStatus("Zone disabled", STATUS_COLORS.error, true);
60986097
debugLog("[GEO AUTH] Setting terminal status for zone disabled");
60996098
} else if (state.disconnectReason === "outside_zone") {
61006099
debugLog("[GEO AUTH] Branch: outside_zone");
6101-
addErrorLogEntry("Disconnected: Outside zone - moved outside wardriving zone boundary", "CONNECTION");
6100+
addErrorLogEntry("Outside zone - moved outside wardriving zone boundary", "CONNECTION");
61026101
setDynamicStatus("Outside zone", STATUS_COLORS.error, true);
61036102
debugLog("[GEO AUTH] Setting terminal status for outside zone");
61046103
} else if (state.disconnectReason === "at_capacity") {
61056104
debugLog("[GEO AUTH] Branch: at_capacity");
6106-
addErrorLogEntry("Disconnected: Zone at capacity - too many active wardrivers in this zone", "CONNECTION");
6105+
addErrorLogEntry("Zone at capacity - too many active wardrivers in this zone", "CONNECTION");
61076106
setDynamicStatus("Zone at capacity", STATUS_COLORS.error, true);
61086107
debugLog("[GEO AUTH] Setting terminal status for zone at capacity");
61096108
} else if (state.disconnectReason === "gps_unavailable") {
61106109
debugLog("[GEO AUTH] Branch: gps_unavailable");
6111-
addErrorLogEntry("Disconnected: GPS unavailable - could not acquire valid GPS coordinates for zone check", "CONNECTION");
6110+
addErrorLogEntry("GPS unavailable - could not acquire valid GPS coordinates for zone check", "CONNECTION");
61126111
setDynamicStatus("GPS unavailable", STATUS_COLORS.error, true);
61136112
debugLog("[GEO AUTH] Setting terminal status for GPS unavailable");
61146113
} else if (state.disconnectReason === "zone_check_failed") {
61156114
debugLog("[GEO AUTH] Branch: zone_check_failed");
6116-
addErrorLogEntry("Disconnected: Zone check failed - unable to verify wardriving zone", "CONNECTION");
6115+
addErrorLogEntry("Zone check failed - unable to verify wardriving zone", "CONNECTION");
61176116
setDynamicStatus("Zone check failed", STATUS_COLORS.error, true);
61186117
debugLog("[GEO AUTH] Setting terminal status for zone check failed");
61196118
} else if (state.disconnectReason === "channel_setup_error") {
61206119
debugLog("[BLE] Branch: channel_setup_error");
61216120
const errorMsg = state.channelSetupErrorMessage || "Channel setup failed";
6122-
addErrorLogEntry(`Disconnected: #wardriving channel setup failed - ${errorMsg}`, "CONNECTION");
6121+
addErrorLogEntry(`#wardriving channel setup failed - ${errorMsg}`, "CONNECTION");
61236122
setDynamicStatus(errorMsg, STATUS_COLORS.error, true);
61246123
debugLog("[BLE] Setting terminal status for channel setup error");
61256124
state.channelSetupErrorMessage = null; // Clear after use (also cleared in cleanup as safety net)
61266125
} else if (state.disconnectReason === "ble_disconnect_error") {
61276126
debugLog("[BLE] Branch: ble_disconnect_error");
61286127
const errorMsg = state.bleDisconnectErrorMessage || "BLE disconnect failed";
6129-
addErrorLogEntry(`Disconnected: BLE connection error - ${errorMsg}`, "CONNECTION");
6128+
addErrorLogEntry(`BLE connection error - ${errorMsg}`, "CONNECTION");
61306129
setDynamicStatus(errorMsg, STATUS_COLORS.error, true);
61316130
debugLog("[BLE] Setting terminal status for BLE disconnect error");
61326131
state.bleDisconnectErrorMessage = null; // Clear after use (also cleared in cleanup as safety net)
@@ -6138,7 +6137,7 @@ async function connect() {
61386137
// For unknown disconnect reasons from API, show a generic message
61396138
debugLog(`[BLE] Showing generic error for unknown reason: ${state.disconnectReason}`);
61406139
const errorMsg = `Connection not allowed: ${state.disconnectReason}`;
6141-
addErrorLogEntry(`Disconnected: Connection not allowed by server (reason: ${state.disconnectReason})`, "CONNECTION");
6140+
addErrorLogEntry(`Connection not allowed by server (reason: ${state.disconnectReason})`, "CONNECTION");
61426141
setDynamicStatus(errorMsg, STATUS_COLORS.error, true);
61436142
}
61446143

0 commit comments

Comments
 (0)