Skip to content

FEAT: Make Error Object Source Allow Objects #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/JsonApiDotNetCore/Internal/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ public class Error
{
public Error()
{ }

[Obsolete("Use Error constructors with int typed status")]
public Error(string status, string title, ErrorMeta meta = null, string source = null)
public Error(string status, string title, ErrorMeta meta = null, object source = null)
{
Status = status;
Title = title;
Meta = meta;
Source = source;
}

public Error(int status, string title, ErrorMeta meta = null, string source = null)
public Error(int status, string title, ErrorMeta meta = null, object source = null)
{
Status = status.ToString();
Title = title;
Expand All @@ -28,7 +28,7 @@ public Error(int status, string title, ErrorMeta meta = null, string source = nu
}

[Obsolete("Use Error constructors with int typed status")]
public Error(string status, string title, string detail, ErrorMeta meta = null, string source = null)
public Error(string status, string title, string detail, ErrorMeta meta = null, object source = null)
{
Status = status;
Title = title;
Expand All @@ -37,29 +37,29 @@ public Error(string status, string title, string detail, ErrorMeta meta = null,
Source = source;
}

public Error(int status, string title, string detail, ErrorMeta meta = null, string source = null)
public Error(int status, string title, string detail, ErrorMeta meta = null, object source = null)
{
Status = status.ToString();
Title = title;
Detail = detail;
Meta = meta;
Source = source;
}

[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("detail")]
public string Detail { get; set; }

[JsonProperty("status")]
public string Status { get; set; }

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

[JsonProperty("source")]
public string Source { get; set; }
public object Source { get; set; }

[JsonProperty("meta")]
public ErrorMeta Meta { get; set; }
Expand All @@ -73,8 +73,8 @@ public class ErrorMeta
[JsonProperty("stackTrace")]
public string[] StackTrace { get; set; }

public static ErrorMeta FromException(Exception e)
=> new ErrorMeta {
public static ErrorMeta FromException(Exception e)
=> new ErrorMeta {
StackTrace = e.Demystify().ToString().Split(new[] { "\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries)
};
}
Expand Down