Skip to content

Commit 3b62d15

Browse files
committed
better error handling
1 parent d4b718b commit 3b62d15

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Assets/UXF/Scripts/Etc/Tracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void RecordRow()
8484
string[] values = GetCurrentValues();
8585

8686
if (values.Length != customHeader.Length)
87-
throw new InvalidDataException(string.Format("GetCurrentValues provided {0} values but expected the same as the number of headers! {1}", values.Length, customHeader.Length));
87+
throw new System.InvalidOperationException(string.Format("GetCurrentValues provided {0} values but expected the same as the number of headers! {1}", values.Length, customHeader.Length));
8888

8989
string[] row = new string[values.Length + 1];
9090

Assets/UXF/Scripts/Session.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,18 @@ public void CopyFileToSessionFolder(string filePath)
277277
/// <param name="dict">Dictionary object to write</param>
278278

279279
/// <param name="objectName">Name of the object (is used for file name)</param>
280-
void WriteDictToSessionFolder(Dictionary<string, object> dict, string objectName)
280+
public void WriteDictToSessionFolder(Dictionary<string, object> dict, string objectName)
281281
{
282-
string fileName = string.Format("{0}.json", objectName);
283-
string filePath = Path.Combine(path, fileName);
284-
fileIOManager.ManageInWorker(() => fileIOManager.WriteJson(filePath, dict));
282+
if (hasInitialised)
283+
{
284+
string fileName = string.Format("{0}.json", objectName);
285+
string filePath = Path.Combine(path, fileName);
286+
fileIOManager.ManageInWorker(() => fileIOManager.WriteJson(filePath, dict));
287+
}
288+
else
289+
{
290+
throw new System.InvalidOperationException("Can't write dictionary before session has initalised!");
291+
}
285292
}
286293

287294

0 commit comments

Comments
 (0)