Skip to content

Commit a050acd

Browse files
committed
feat: Error should accept objects for source
1 parent 9c54535 commit a050acd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/JsonApiDotNetCore/Internal/Error.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ public class Error
99
{
1010
public Error()
1111
{ }
12-
12+
1313
[Obsolete("Use Error constructors with int typed status")]
14-
public Error(string status, string title, ErrorMeta meta = null, string source = null)
14+
public Error(string status, string title, ErrorMeta meta = null, object source = null)
1515
{
1616
Status = status;
1717
Title = title;
1818
Meta = meta;
1919
Source = source;
2020
}
2121

22-
public Error(int status, string title, ErrorMeta meta = null, string source = null)
22+
public Error(int status, string title, ErrorMeta meta = null, object source = null)
2323
{
2424
Status = status.ToString();
2525
Title = title;
@@ -28,7 +28,7 @@ public Error(int status, string title, ErrorMeta meta = null, string source = nu
2828
}
2929

3030
[Obsolete("Use Error constructors with int typed status")]
31-
public Error(string status, string title, string detail, ErrorMeta meta = null, string source = null)
31+
public Error(string status, string title, string detail, ErrorMeta meta = null, object source = null)
3232
{
3333
Status = status;
3434
Title = title;
@@ -37,29 +37,29 @@ public Error(string status, string title, string detail, ErrorMeta meta = null,
3737
Source = source;
3838
}
3939

40-
public Error(int status, string title, string detail, ErrorMeta meta = null, string source = null)
40+
public Error(int status, string title, string detail, ErrorMeta meta = null, object source = null)
4141
{
4242
Status = status.ToString();
4343
Title = title;
4444
Detail = detail;
4545
Meta = meta;
4646
Source = source;
4747
}
48-
48+
4949
[JsonProperty("title")]
5050
public string Title { get; set; }
5151

5252
[JsonProperty("detail")]
5353
public string Detail { get; set; }
54-
54+
5555
[JsonProperty("status")]
5656
public string Status { get; set; }
5757

5858
[JsonIgnore]
5959
public int StatusCode => int.Parse(Status);
6060

6161
[JsonProperty("source")]
62-
public string Source { get; set; }
62+
public object Source { get; set; }
6363

6464
[JsonProperty("meta")]
6565
public ErrorMeta Meta { get; set; }
@@ -73,8 +73,8 @@ public class ErrorMeta
7373
[JsonProperty("stackTrace")]
7474
public string[] StackTrace { get; set; }
7575

76-
public static ErrorMeta FromException(Exception e)
77-
=> new ErrorMeta {
76+
public static ErrorMeta FromException(Exception e)
77+
=> new ErrorMeta {
7878
StackTrace = e.Demystify().ToString().Split(new[] { "\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries)
7979
};
8080
}

0 commit comments

Comments
 (0)