Throw retrieve meter values error directly in Schneider Asset Integration
MODIFY
src/integration/asset/schneider/SchneiderAssetIntegration.ts
src/integration/asset/schneider/SchneiderAssetIntegration.ts
@@ -33,6 +33,7 @@ export default class SchneiderAssetIntegration extends AssetIntegration<AssetSet
public async retrieveMeterValues(asset: Asset): Promise<AbstractConsumption> {
// Set new Token
await this.setToken();
+ try {
// Get consumption
const { data } = await axios.get(
`${this.connection.url}/Containers/${Constants.DEFAULT_ASSET_SCHNEIDER_BASE_ID}${asset.meterID}/Children`,
@@ -43,6 +44,16 @@ export default class SchneiderAssetIntegration extends AssetIntegration<AssetSet
if (data && data.length > 0) {
return this.filterConsumptionRequest(asset, data);
}
+ } catch (error) {
+ throw new BackendError({
+ source: Constants.CENTRAL_SERVER,
+ module: MODULE_NAME,
+ method: 'retrieveMeterValues',
+ action: ServerAction.REFRESH_ASSET_CONNECTION,
+ message: 'Error while retrieving meter values',
+ detailedMessages: { error: error.message, stack: error.stack }
+ });
+ }
return null;
}

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1955,22 +1955,9 @@ export default class Utils {
});
}
// Call to BMS backend
- try {
const consumption = await assetImpl.retrieveMeterValues(asset);
// Store consumption to Asset
asset.consumption = consumption;
- } catch (error) {
- throw new AppError({
- source: Constants.CENTRAL_SERVER,
- errorCode: HTTPError.GENERAL_ERROR,
- message: 'Error occurred while retrieving metrics',
- module: MODULE_NAME,
- method: 'retrieveAssetMetrics',
- action: action,
- user: req.user,
- detailedMessages: { error: error.message, stack: error.stack }
- });
- }
// Save Asset
await AssetStorage.saveAsset(req.user.tenantID, asset);
}

Throw retrieve meter values error directly in Schneider Asset Integration