aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-11-27 08:54:08 +0100
committerivarlovlie <git@ivarlovlie.no>2022-11-27 08:54:08 +0100
commita4d94eb40ab52ffbc9f1e9647d5cc29edae18905 (patch)
tree4488c47b7f46fd5fefc55184cd128211ba012796 /code/api/src
parent5c69dacebaa9a330932dcbf54574093ec1b869f5 (diff)
downloadgreatoffice-a4d94eb40ab52ffbc9f1e9647d5cc29edae18905.tar.xz
greatoffice-a4d94eb40ab52ffbc9f1e9647d5cc29edae18905.zip
feat: Initialise Errors dictionary in constructor
This mitigates a possible NRE if no errors has been added
Diffstat (limited to 'code/api/src')
-rw-r--r--code/api/src/Data/Models/KnownProblemModel.cs6
1 files changed, 1 insertions, 5 deletions
diff --git a/code/api/src/Data/Models/KnownProblemModel.cs b/code/api/src/Data/Models/KnownProblemModel.cs
index 818a295..9acc85c 100644
--- a/code/api/src/Data/Models/KnownProblemModel.cs
+++ b/code/api/src/Data/Models/KnownProblemModel.cs
@@ -5,7 +5,7 @@ public class KnownProblemModel
public KnownProblemModel(string title = default, string subtitle = default, Dictionary<string, string[]> errors = default) {
Title = title;
Subtitle = subtitle;
- Errors = errors;
+ Errors = errors ?? new();
}
public string Title { get; set; }
@@ -14,10 +14,6 @@ public class KnownProblemModel
public string TraceId { get; set; }
public void AddError(string field, string errorText) {
- if (Errors == default) {
- Errors = new Dictionary<string, string[]>();
- }
-
if (!Errors.ContainsKey(field)) {
Errors.Add(field, new[] {errorText});
} else {