-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaJaMaResults.cs
73 lines (62 loc) · 1.35 KB
/
PaJaMaResults.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PaJaMaCommon
{
public class PaJaMaResults
{
private List<string> _warnings = new List<string>();
private List<string> _errors = new List<string>();
private List<Exception> _systemExceptions = new List<Exception>();
public void Add(PaJaMaResults results)
{
Errors.AddRange(results.Errors);
Warnings.AddRange(results.Warnings);
SystemExceptions.AddRange(results.SystemExceptions);
}
public void Throw()
{
if (Failed)
throw new Exception(this.ErrorText);
}
public bool Failed
{
get
{
return (_errors.Count > 0 || _systemExceptions.Count > 0);
}
}
public List<string> Warnings
{
get { return _warnings; }
}
public List<string> Errors
{
get { return _errors; }
}
public List<Exception> SystemExceptions
{
get { return _systemExceptions; }
}
public string ErrorText
{
get
{
StringBuilder sb = new StringBuilder();
foreach (string err in this.Errors) sb.AppendLine(err);
foreach (Exception ex in this.SystemExceptions)
{
sb.AppendLine(ex.Message);
Exception innerEx = ex.InnerException;
while (innerEx != null)
{
sb.AppendLine("\t" + innerEx.Message);
innerEx = innerEx.InnerException;
}
}
return sb.ToString();
}
}
}
}