-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathResult.cs
41 lines (34 loc) · 913 Bytes
/
Result.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
using System.Text;
namespace UnityEditorPatch;
public class Result
{
public bool IsSucceed { get; private init; }
public string[] Errors { get; private init; } = [];
public string Message { get; private init; } = string.Empty;
public static Result Success(string message) => new()
{
IsSucceed = true,
Message = message
};
public static Result Error(params string[] errors) => new()
{
Errors = errors,
IsSucceed = false
};
public override string ToString()
{
var stringBuilder = new StringBuilder();
if (IsSucceed)
{
stringBuilder.AppendLine($"SUCCESS: {Message}");
}
else
{
foreach (var error in Errors)
{
stringBuilder.AppendLine($"ERROR: {error}");
}
}
return stringBuilder.ToString();
}
}