Skip to content

Commit 0af4961

Browse files
committed
Fixed exception not being caught when an issue arises when serialising or deserialising the preferences file (issue present in Unity 2021.2).
1 parent 9928969 commit 0af4961

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
- Fixed exception not being caught when an issue occurs serialising or deserialising the preferences file.
89

910
## [1.0.0] - 2021-08-22
1011
- Initial major release.

Runtime/DevConsoleData.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Purpose: Static class for accessing saved developer console preferences.
33
// Created by: DavidFDev
44

5+
using System;
56
using System.Collections.Generic;
67
using System.IO;
78
using System.Runtime.Serialization.Formatters.Binary;
@@ -54,6 +55,11 @@ public static void Save()
5455
{
5556
bf.Serialize(fs, _data);
5657
}
58+
catch (Exception e)
59+
{
60+
DevConsole.LogException(e);
61+
DevConsole.LogError("Failed to save developer console preferences due to an exception.");
62+
}
5763
finally
5864
{
5965
fs.Close();
@@ -74,6 +80,11 @@ public static void Load()
7480
{
7581
_data = (Dictionary<string, object>)bf.Deserialize(fs);
7682
}
83+
catch (Exception e)
84+
{
85+
DevConsole.LogException(e);
86+
DevConsole.LogError("Failed to load developer console preferences due an exception.");
87+
}
7788
finally
7889
{
7990
fs.Close();

0 commit comments

Comments
 (0)