forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebServiceException.cs
More file actions
73 lines (64 loc) · 1.64 KB
/
WebServiceException.cs
File metadata and controls
73 lines (64 loc) · 1.64 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
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 ServiceStack.Text;
namespace ServiceStack.ServiceClient.Web
{
public class WebServiceException
: Exception
{
public WebServiceException() { }
public WebServiceException(string message) : base(message) { }
public WebServiceException(string message, Exception innerException) : base(message, innerException) { }
public int StatusCode { get; set; }
public object ResponseDto { get; set; }
private string errorCode;
private void ParseResponseDto()
{
if (ResponseDto == null) return;
var jsv = TypeSerializer.SerializeToString(ResponseDto);
var map = TypeSerializer.DeserializeFromString<Dictionary<string, string>>(jsv);
string responseStatus;
if (!map.TryGetValue("ResponseStatus", out responseStatus)) return;
var rsMap = TypeSerializer.DeserializeFromString<Dictionary<string, string>>(responseStatus);
if (rsMap == null) return;
rsMap.TryGetValue("ErrorCode", out errorCode);
rsMap.TryGetValue("Message", out errorMessage);
rsMap.TryGetValue("StackTrace", out serverStackTrace);
}
public string ErrorCode
{
get
{
if (errorCode == null)
{
ParseResponseDto();
}
return errorCode;
}
}
private string errorMessage;
public string ErrorMessage
{
get
{
if (errorMessage == null)
{
ParseResponseDto();
}
return errorMessage;
}
}
private string serverStackTrace;
public string ServerStackTrace
{
get
{
if (serverStackTrace == null)
{
ParseResponseDto();
}
return serverStackTrace;
}
}
}
}