This repository was archived by the owner on Nov 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExtensions.cs
More file actions
44 lines (42 loc) · 1.65 KB
/
Copy pathExtensions.cs
File metadata and controls
44 lines (42 loc) · 1.65 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Plexo.Client.SDK.Logging;
using Plexo.Exceptions;
namespace Plexo.Client.SDK
{
public static class Extensions
{
public static void PopulateFromException(this ServerResponse resp, ResultCodeException exception, ILog log = null)
{
resp.I18NErrorMessages = exception.I18NErrorMessages;
resp.ErrorMessage = exception.ErrorMessage;
resp.ResultCode = exception.Code;
if (log != null)
if (exception.IsErrorLogged || exception.OriginalException != null)
if (exception.OriginalException != null)
log.ErrorException(resp.ErrorMessage, exception.OriginalException);
else
log.ErrorException(resp.ErrorMessage, exception);
else
log.Debug(resp.ErrorMessage);
}
public static void PopulateFromException(this ServerResponse resp, Exception exception, ILog log = null)
{
if (exception is ResultCodeException)
{
resp.PopulateFromException((ResultCodeException)exception, log);
return;
}
resp.ResultCode = ResultCodes.SystemError;
resp.I18NErrorMessages = new Dictionary<string, string>
{
{"en", "System Error, please try later"},
{"es", "Error del Sistema, pruebe nuevamente mas tarde"}
};
resp.ErrorMessage = resp.I18NErrorMessages["en"];
log?.ErrorException(resp.ErrorMessage, exception);
}
}
}