Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 8a8d4835 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

Aux: better error message if Technology is not a list

parent f1fddb9c
No related branches found
No related tags found
No related merge requests found
......@@ -29,13 +29,13 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
......@@ -45,7 +45,6 @@ using TUGraz.VectoCore.InputData.Impl;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
using AuxiliaryTypeHelper = TUGraz.VectoCore.Models.Declaration.AuxiliaryTypeHelper;
namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
......@@ -53,8 +52,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
private string _basePath;
protected JObject Header;
protected JObject Body;
protected readonly JObject Header;
protected readonly JObject Body;
protected JSONFile(JObject data, string filename)
{
......@@ -63,11 +62,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
BasePath = filename;
}
public int FileVersion
{
get { return Header.GetEx(JsonKeys.JsonHeader_FileVersion).Value<int>(); }
}
public bool SavedInDeclarationMode
{
get { return Body.GetEx(JsonKeys.SavedInDeclMode).Value<bool>(); }
......@@ -86,7 +80,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
return VectoCSVFile.Read(Path.Combine(BasePath, filename), true);
} catch (Exception e) {
Log.Warn("Failed to read file {0} {1}", Path.Combine(BasePath, filename), tableType);
throw new VectoException(string.Format("Failed to read file for {0}: {1}", tableType, filename), e);
throw new VectoException("Failed to read file for {0}: {1}", e, tableType, filename);
}
}
if (required) {
......@@ -111,13 +105,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
IEngineeringJobInputData, IDriverEngineeringInputData, IAuxiliariesEngineeringInputData,
IAuxiliariesDeclarationInputData
{
protected IGearboxEngineeringInputData Gearbox;
protected IAxleGearInputData AxleGear;
protected ITorqueConverterEngineeringInputData TorqueConverter;
public IAngularGearInputData AngularGear;
protected IEngineEngineeringInputData Engine;
protected IVehicleEngineeringInputData VehicleData;
protected IRetarderInputData Retarder;
protected readonly IGearboxEngineeringInputData Gearbox;
protected readonly IAxleGearInputData AxleGear;
protected readonly ITorqueConverterEngineeringInputData TorqueConverter;
protected readonly IAngularGearInputData AngularGear;
protected readonly IEngineEngineeringInputData Engine;
protected readonly IVehicleEngineeringInputData VehicleData;
protected readonly IRetarderInputData Retarder;
private readonly string _jobname;
......@@ -590,10 +584,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
var retVal = new List<AuxiliaryDataInputData>();
foreach (var aux in Body["Aux"] ?? Enumerable.Empty<JToken>()) {
try {
aux.GetEx("Technology").ToObject<List<string>>();
} catch (Exception) {
throw new VectoException(
"Aux: Technology for aux '{0}' list could not be read. Maybe it is a single string instead of a list of strings?",
aux.GetEx<string>("ID"));
}
var auxData = new AuxiliaryDataInputData {
ID = aux.GetEx<string>("ID"),
Type = AuxiliaryTypeHelper.Parse(aux.GetEx<string>("Type")),
Technology = aux.GetEx<List<string>>("Technology"),
Technology = aux.GetEx("Technology").ToObject<List<string>>()
};
var auxFile = aux["Path"];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment