Adding changes to AppError
MODIFY
src/exception/AppError.ts
src/exception/AppError.ts
@@ -11,6 +11,7 @@ export default class AppError extends Error {
source: string; message: string; errorCode: HTTPError | StatusCodes; module: string;
method: string; user?: User | string | UserToken; actionOnUser?: User | string | UserToken;
action?: ServerAction; detailedMessages?: any; ocpiError?: OCPIStatusCode; oicpError?: OICPStatusCode;
+ chargingStationID?: string; siteID?: string; siteAreaID?: string; companyID?: string;
}) {
super(params.message);
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -96,6 +96,10 @@ export default class ChargingStationService {
if (Utils.isComponentActiveFromToken(req.user, TenantComponents.ORGANIZATION) && filteredRequest.public && !siteArea.site?.public) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.FEATURE_NOT_SUPPORTED_ERROR,
message: `Cannot set charging station ${chargingStation.id} attached to the non public site ${siteArea.site.name} public`,
@@ -389,6 +393,10 @@ export default class ChargingStationService {
if (!chargingStationVendor) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.FEATURE_NOT_SUPPORTED_ERROR,
message: `No vendor implementation is available (${chargingStation.chargePointVendor}) for limiting the charge`,
@@ -400,6 +408,10 @@ export default class ChargingStationService {
if (!chargingStationVendor.hasStaticLimitationSupport(chargingStation)) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.FEATURE_NOT_SUPPORTED_ERROR,
message: 'Charging Station does not support power limitation',
@@ -433,6 +445,10 @@ export default class ChargingStationService {
if (!filteredRequest.forceUpdateChargingPlan) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
user: req.user,
errorCode: HTTPError.GENERAL_ERROR,
@@ -466,6 +482,10 @@ export default class ChargingStationService {
if (result.status !== OCPPConfigurationStatus.ACCEPTED && result.status !== OCPPConfigurationStatus.REBOOT_REQUIRED) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.LIMIT_POWER_ERROR,
module: MODULE_NAME, method: 'handleChargingStationLimitPower',
@@ -1650,6 +1670,10 @@ export default class ChargingStationService {
// Throw error
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.GENERAL_ERROR,
message: `Unknown OCPP command '${command}'`,
@@ -1660,6 +1684,10 @@ export default class ChargingStationService {
} catch (error) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.GENERAL_ERROR,
message: `OCPP Command '${command}' has failed`,
@@ -1711,6 +1739,10 @@ export default class ChargingStationService {
if (!chargingStation.capabilities?.supportChargingProfiles) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.FEATURE_NOT_SUPPORTED_ERROR,
user: req.user,
@@ -1740,6 +1772,10 @@ export default class ChargingStationService {
if (!chargingStationVendor) {
throw new AppError({
source: chargingStation.id,
+ chargingStationID: chargingStation.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
action: action,
errorCode: HTTPError.FEATURE_NOT_SUPPORTED_ERROR,
message: `No vendor implementation is available (${chargingStation.chargePointVendor}) for limiting the charge`,

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -648,6 +648,10 @@ export default class Logging {
tenantID: tenantID,
type: LogType.SECURITY,
source: exception.params.source,
+ chargingStationID: exception.params.chargingStationID,
+ siteID: exception.params.siteID,
+ siteAreaID: exception.params.siteAreaID,
+ companyID: exception.params.companyID,
user: exception.params.user,
actionOnUser: exception.params.actionOnUser,
module: exception.params.module,

Adding changes to AppError