diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-11-27 08:54:08 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-11-27 08:54:08 +0100 |
| commit | a4d94eb40ab52ffbc9f1e9647d5cc29edae18905 (patch) | |
| tree | 4488c47b7f46fd5fefc55184cd128211ba012796 /code/api | |
| parent | 5c69dacebaa9a330932dcbf54574093ec1b869f5 (diff) | |
| download | greatoffice-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')
| -rw-r--r-- | code/api/src/Data/Models/KnownProblemModel.cs | 6 |
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 { |
