Skip to content

Commit

Permalink
Removed blank error message reporting that could show up as undefined.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstrouse committed May 23, 2023
1 parent 7277582 commit 9eb0f5d
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion controller/nixie/NixieEquipment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class NixieEquipment {
public async closeAsync() {
try {
}
catch (err) { logger.error(err); }
catch (err) { logger.error(`Error closing Nixie Equipment: ${err.message}`); }
}
}
export class NixieChildEquipment extends NixieEquipment {
Expand Down
18 changes: 8 additions & 10 deletions controller/nixie/chemistry/ChemController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1370,8 +1370,7 @@ export class NixieChemPump extends NixieChildEquipment {
await self.dose(schem);
}
catch (err) {
logger.error(`self.dose error in finally:`);
logger.error(err);
logger.error(`self.dose error in finally: ${err.message}`);
//return Promise.reject(err); // this isn't a promise we should be returning
}
}, 1000);
Expand All @@ -1383,8 +1382,7 @@ export class NixieChemPump extends NixieChildEquipment {
await this.chemical.cancelDosing(schem, 'completed');
}
catch (err) {
logger.error(`this.chemical.cancelDosing error in finally:`);
logger.error(err);
logger.error(`this.chemical.cancelDosing error in finally: ${err.message}`);
}
schem.pump.isDosing = this.isOn = false;
schem.manualDosing = false;
Expand Down Expand Up @@ -1538,7 +1536,7 @@ export class NixieChemChlor extends NixieChildEquipment {
this._dosingTimer = setTimeout(async () => {
try { await self.dose(schem); }
catch (err) {
logger.error(err);
logger.error(`Chem dosing error: ${err.message}`);
// return Promise.reject(err); // should not be returning a promise in a finally
}
}, 1000);
Expand Down Expand Up @@ -1818,7 +1816,7 @@ export class NixieChemicalPh extends NixieChemical {
}
}
}
catch (err) { logger.error(err); return Promise.reject(err); }
catch (err) { logger.error(`Error checking for dosing: ${err.message}`); return Promise.reject(err); }
finally {
logger.debug(`End check ${sph.chemType} dosing status = ${sys.board.valueMaps.chemControllerDosingStatus.getName(sph.dosingStatus)}`);
}
Expand Down Expand Up @@ -1870,7 +1868,7 @@ export class NixieChemicalPh extends NixieChemical {
logger.verbose(`Chem acid manual calibration dose activate pump`);
await this.pump.dose(sph);
}
catch (err) { logger.error(`calibrateDoseAsync: ${err.message}`); logger.error(err); return Promise.reject(err); }
catch (err) { logger.error(`calibrateDoseAsync: ${err.message}`); return Promise.reject(err); }
}
public async manualDoseVolumeAsync(sph: ChemicalPhState, volume: number) {
try {
Expand Down Expand Up @@ -1903,7 +1901,7 @@ export class NixieChemicalPh extends NixieChemical {
await this.pump.dose(sph);
}
}
catch (err) { logger.error(`manualDoseVolumeAsync: ${err.message}`); logger.error(err); return Promise.reject(err); }
catch (err) { logger.error(`manualDoseVolumeAsync: ${err.message}`); return Promise.reject(err); }
}
public async initDose(sph: ChemicalPhState) {
try {
Expand Down Expand Up @@ -2024,7 +2022,7 @@ export class NixieChemicalORP extends NixieChemical {
await this.pump.dose(sorp);
}
}
catch (err) { logger.error(`manualDoseVolumeAsync ORP: ${err.message}`); logger.error(err); return Promise.reject(err); }
catch (err) { logger.error(`manualDoseVolumeAsync ORP: ${err.message}`); return Promise.reject(err); }
}
public async calibrateDoseAsync(sorp: ChemicalORPState, time: number) {
try {
Expand Down Expand Up @@ -2055,7 +2053,7 @@ export class NixieChemicalORP extends NixieChemical {
logger.verbose(`Chem acid manual dose activate pump ${this.pump.pump.ratedFlow}mL/min`);
await this.pump.dose(sorp);
}
catch (err) { logger.error(`calibrateDoseAsync: ${err.message}`); logger.error(err); return Promise.reject(err); }
catch (err) { logger.error(`calibrateDoseAsync: ${err.message}`); return Promise.reject(err); }
}

public async cancelDosing(sorp: ChemicalORPState, reason: string): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions controller/nixie/pumps/Pump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export class NixiePumpRS485 extends NixiePump {
let pstate = state.pumps.getItemById(this.pump.id);
pstate.command = pstate.rpm > 0 || pstate.flow > 0 ? 10 : 0;
}
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`Error setting driveState for ${this.pump.name}: ${err.message}`); }
};
protected async requestPumpStatusAsync() {
if (conn.isPortEnabled(this.pump.portId || 0)) {
Expand Down Expand Up @@ -636,7 +636,7 @@ export class NixiePumpRS485 extends NixiePump {
logger.error(`Error sending setPumpToRemoteControl for ${this.pump.name}: ${err.message}`);
}
}
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`Error setting pump to Remote Control for ${this.pump.name}: ${err.message}`); }
}
protected async setPumpFeatureAsync(feature?: number) {
// empty payload (possibly 0?, too) is no feature
Expand All @@ -659,7 +659,7 @@ export class NixiePumpRS485 extends NixiePump {
logger.error(`Error sending setPumpFeature for ${this.pump.name}: ${err.message}`);
}
}
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`Error setting pump feature for ${this.pump.name}: ${err.message}`); }
};
protected async setPumpRPMAsync() {
if (conn.isPortEnabled(this.pump.portId || 0)) {
Expand Down
14 changes: 7 additions & 7 deletions logger/DataLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class DataLogger {
} catch (err) { logger.error(`Skipping invalid dose history entry: ${err.message}`); }
}
return arr;
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`Skipping dose history ${err.message}`); }
}
// This method uses a callback to end the file read from the end of the file. If the callback returns false then the iteration through the
// file will end and the log entries will be returned. If the callback returns true then the entry will be added to the
Expand Down Expand Up @@ -103,11 +103,11 @@ export class DataLogger {
}
catch (err) { return Promise.reject(err); }
finally { if (typeof file !== 'undefined') await new Promise<boolean>((resolve, reject) => fs.close(file, (err) => { if (err) reject(err); else resolve(true); })); }
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`readFromEndAsync: ${err.message}`); }
}
return arr;
}
catch (err) { logger.error(err); }
catch (err) { logger.error(`readFromEndAsync: ${logFile} ${err.message}`); }

}
// This method uses a callback to end the file read from the end of the file. If the callback returns false then the iteration through the
Expand Down Expand Up @@ -235,11 +235,11 @@ export class DataLogger {
}
catch (err) { return Promise.reject(err); }
finally { if (typeof file !== 'undefined') await new Promise<boolean>((resolve, reject) => fs.close(file, (err) => { if (err) reject(err); else resolve(true); })); }
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`readFromStart: ${err.message}`); }
}
return arr;
}
catch (err) { logger.error(err); }
catch (err) { logger.error(`readFromStart ${logFile}: ${err.message}`); }

}

Expand Down Expand Up @@ -316,7 +316,7 @@ export class DataLogger {
else
lines.unshift(data.toString());
fs.writeFileSync(logPath, lines.join('\n'));
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`writeStart ${logFile}: ${err.message}`); }
}
public static writeEnd(logFile: string, entry: DataLoggerEntry) {
try {
Expand Down Expand Up @@ -384,7 +384,7 @@ export class DataLogger {
finally { if (typeof file !== 'undefined') await new Promise<boolean>((resolve, reject) => fs.close(file, (err) => { if (err) reject(err); else resolve(true); })); }
}
return lines;
} catch (err) { logger.error(err); }
} catch (err) { logger.error(`readEnd ${logFile}: ${err.message}`); }
}
private static makeLogFilePath(logFile: string) { return `${DataLogger.ensureLogPath()}/${logFile}`; }
private static ensureLogPath(): string {
Expand Down
2 changes: 1 addition & 1 deletion web/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ export class REMInterfaceServer extends ProtoServer {
}
return (response.status.code === 200) ? JSON.parse(response.data) : [];
}
catch (err) { logger.error(err); }
catch (err) { logger.error(`getDevices: ${err.message}`); }
}
}
export class BackupFile {
Expand Down
2 changes: 1 addition & 1 deletion web/services/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ export class ConfigRoute {
} catch (e) {
err = new ServiceProcessError(`Error uploading file: ${e.message}`, 'POST: app/backup/file', 'uploadFile');
next(err);
logger.error(e);
logger.error(`Error uploading file ${e.message}`);
}
});
} catch (err) { next(err); }
Expand Down
4 changes: 2 additions & 2 deletions web/services/state/StateSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class StateSocket {
sock.on('/temps', async (data: any) => {
try {
data = JSON.parse(data);
await sys.board.system.setTempsAsync(data).catch(err => logger.error(err));
await sys.board.system.setTempsAsync(data).catch(err => logger.error(`setTempsAsync: ${err.message}`));
}
catch (err) { logger.error(`Socket processing error /temps: ${err.message}`); }
});
Expand Down Expand Up @@ -197,7 +197,7 @@ export class StateSocket {
await sys.board.circuits.setCircuitStateAsync(id, utils.makeBool(data.isOn || typeof data.state));
}
}
catch (err) { logger.error(err); }
catch (err) { logger.error(`Socket /circuit error: ${err.message}`); }
});
sock.on('/feature', async (data: any) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion web/services/utilities/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class UtilitiesRoute {
} catch (e) {
err = new ServiceProcessError(`Error uploading file: ${e.message}`, 'POST: app/backup/file', 'uploadFile');
next(err);
logger.error(e);
logger.error(`File upload error: ${e.message}`);
}
});
} catch (err) { next(err); }
Expand Down

0 comments on commit 9eb0f5d

Please sign in to comment.