File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/JsonApiDotNetCore/Controllers Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
1
2
using System . Linq ;
2
3
using JsonApiDotNetCore . Internal ;
3
4
using Microsoft . AspNetCore . Mvc ;
@@ -16,6 +17,17 @@ protected IActionResult Forbidden()
16
17
return new StatusCodeResult ( 403 ) ;
17
18
}
18
19
20
+ protected IActionResult Error ( Error error )
21
+ {
22
+ var errorCollection = new ErrorCollection {
23
+ Errors = new List < Error > { error }
24
+ } ;
25
+ var result = new ObjectResult ( errorCollection ) ;
26
+ result . StatusCode = error . StatusCode ;
27
+
28
+ return result ;
29
+ }
30
+
19
31
protected IActionResult Errors ( ErrorCollection errors )
20
32
{
21
33
var result = new ObjectResult ( errors ) ;
@@ -27,7 +39,7 @@ protected IActionResult Errors(ErrorCollection errors)
27
39
private int GetErrorStatusCode ( ErrorCollection errors )
28
40
{
29
41
var statusCodes = errors . Errors
30
- . Select ( e => ( int ) e . StatusCode )
42
+ . Select ( e => e . StatusCode )
31
43
. Distinct ( )
32
44
. ToList ( ) ;
33
45
You can’t perform that action at this time.
0 commit comments