-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from bart-degreed/extensibility
Error handling and logging
- Loading branch information
Showing
174 changed files
with
4,000 additions
and
1,778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Examples/JsonApiDotNetCoreExample/Controllers/ThrowingResourcesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using JsonApiDotNetCore.Configuration; | ||
using JsonApiDotNetCore.Controllers; | ||
using JsonApiDotNetCore.Services; | ||
using JsonApiDotNetCoreExample.Models; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace JsonApiDotNetCoreExample.Controllers | ||
{ | ||
public sealed class ThrowingResourcesController : JsonApiController<ThrowingResource> | ||
{ | ||
public ThrowingResourcesController( | ||
IJsonApiOptions jsonApiOptions, | ||
ILoggerFactory loggerFactory, | ||
IResourceService<ThrowingResource> resourceService) | ||
: base(jsonApiOptions, loggerFactory, resourceService) | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using JsonApiDotNetCore.Models; | ||
|
||
namespace JsonApiDotNetCoreExample.Models | ||
{ | ||
public class Tag : Identifiable | ||
{ | ||
[Attr] | ||
[RegularExpression(@"^\W$")] | ||
public string Name { get; set; } | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Examples/JsonApiDotNetCoreExample/Models/ThrowingResource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using JsonApiDotNetCore.Formatters; | ||
using JsonApiDotNetCore.Models; | ||
|
||
namespace JsonApiDotNetCoreExample.Models | ||
{ | ||
public sealed class ThrowingResource : Identifiable | ||
{ | ||
[Attr] | ||
public string FailsOnSerialize | ||
{ | ||
get | ||
{ | ||
var isSerializingResponse = new StackTrace().GetFrames() | ||
.Any(frame => frame.GetMethod().DeclaringType == typeof(JsonApiWriter)); | ||
|
||
if (isSerializingResponse) | ||
{ | ||
throw new InvalidOperationException($"The value for the '{nameof(FailsOnSerialize)}' property is currently unavailable."); | ||
} | ||
|
||
return string.Empty; | ||
} | ||
set { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.