notification - log exceptions
MODIFY
src/integration/smart-charging/SmartChargingIntegration.ts
src/integration/smart-charging/SmartChargingIntegration.ts
@@ -134,13 +134,23 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
// Remember Charging Stations which were removed from Smart Charging
this.excludedChargingStations.push(chargingStation.id);
// Notify Admins
- void NotificationHandler.sendComputeAndApplyChargingProfilesFailed(tenant, chargingStation,
+ NotificationHandler.sendComputeAndApplyChargingProfilesFailed(tenant, chargingStation,
{ chargeBoxID: chargingProfile.chargingStationID,
siteID: chargingProfile.chargingStation?.siteID,
siteAreaID: chargingProfile.chargingStation?.siteAreaID,
companyID: chargingProfile.chargingStation?.companyID,
siteAreaName: siteAreaName,
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
+ }
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
});
return false;
}

MODIFY
src/utils/NotificationHelper.ts
src/utils/NotificationHelper.ts
import ChargingStation from '../types/ChargingStation';
import Constants from './Constants';
import I18nManager from './I18nManager';
+import Logging from './Logging';
import NotificationHandler from '../notification/NotificationHandler';
+import { ServerAction } from '../types/Server';
import Tenant from '../types/Tenant';
import Transaction from '../types/Transaction';
import User from '../types/User';
import Utils from './Utils';
import moment from 'moment';
+const MODULE_NAME = 'NotificationHelper';
+
export default class NotificationHelper {
public static notifyStartTransaction(tenant: Tenant, transaction: Transaction, chargingStation: ChargingStation, user: User) {
if (user) {
- void NotificationHandler.sendTransactionStarted(
+ NotificationHandler.sendTransactionStarted(
tenant,
transaction.id.toString(),
user,
@@ -27,7 +31,16 @@ export default class NotificationHelper {
'evseDashboardURL': Utils.buildEvseURL(tenant.subdomain),
'evseDashboardChargingStationURL': Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#inprogress')
}
- );
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
+ });
}
}
@@ -36,7 +49,7 @@ export default class NotificationHelper {
// Get the i18n lib
const i18nManager = I18nManager.getInstanceForLocale(transaction.user.locale);
// Notify (Async)
- void NotificationHandler.sendEndOfCharge(
+ NotificationHandler.sendEndOfCharge(
tenant,
transaction.id.toString() + '-EOC',
transaction.user,
@@ -55,7 +68,16 @@ export default class NotificationHelper {
evseDashboardChargingStationURL: Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#inprogress'),
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
}
- );
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
+ });
}
}
@@ -64,7 +86,7 @@ export default class NotificationHelper {
// Get the i18n lib
const i18nManager = I18nManager.getInstanceForLocale(transaction.user.locale);
// Notification Before End Of Charge (Async)
- void NotificationHandler.sendOptimalChargeReached(
+ NotificationHandler.sendOptimalChargeReached(
tenant,
transaction.id.toString() + '-OCR',
transaction.user,
@@ -82,7 +104,16 @@ export default class NotificationHelper {
evseDashboardChargingStationURL: Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#inprogress'),
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
}
- );
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
+ });
}
}
@@ -92,7 +123,7 @@ export default class NotificationHelper {
// Get the i18n lib
const i18nManager = I18nManager.getInstanceForLocale(user.locale);
// Send Notification (Async)
- void NotificationHandler.sendEndOfTransaction(
+ NotificationHandler.sendEndOfTransaction(
tenant,
transaction.id.toString() + '-EOS',
user,
@@ -113,12 +144,21 @@ export default class NotificationHelper {
evseDashboardChargingStationURL: Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#history'),
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
}
- );
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
+ });
// Notify Signed Data
if (transaction.stop.signedData !== '') {
// Send Notification (Async)
const locale = user.locale ? user.locale.replace('_', '-') : Constants.DEFAULT_LOCALE.replace('_', '-');
- void NotificationHandler.sendEndOfSignedTransaction(
+ NotificationHandler.sendEndOfSignedTransaction(
tenant,
transaction.id.toString() + '-EOSS',
user,
@@ -145,7 +185,16 @@ export default class NotificationHelper {
evseDashboardChargingStationURL: Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#history'),
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
}
- );
+ ).catch((error) => {
+ // TODO - This should be done everywhere!
+ Logging.logError({
+ tenantID: tenant.id,
+ action: ServerAction.NOTIFICATION,
+ module: MODULE_NAME, method: 'notificationHelper',
+ message: 'Notification failed',
+ detailedMessages: { error: error.stack }
+ }).catch(() => { /* Intentional */ });
+ });
}
}
}

notification - log exceptions