forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorServices.cs
More file actions
51 lines (44 loc) · 1.32 KB
/
Copy pathErrorServices.cs
File metadata and controls
51 lines (44 loc) · 1.32 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
using System;
using Check.ServiceModel;
using ServiceStack;
using ServiceStack.Web;
namespace Check.ServiceInterface
{
public class CustomHttpErrorService : Service
{
public object Any(CustomHttpError request)
{
throw new HttpError(request.StatusCode, request.StatusDescription);
}
public object Any(AlwaysThrows request)
{
throw new Exception(request.GetType().Name);
}
}
public class AlwaysThrowsService : Service
{
[AlwaysThrows]
public object Any(AlwaysThrowsFilterAttribute request) => request;
public object Any(AlwaysThrowsGlobalFilter request) => request;
}
public class AlwaysThrowsAttribute : RequestFilterAttribute
{
public override void Execute(IRequest req, IResponse res, object requestDto)
{
throw new Exception(requestDto.GetType().Name);
}
}
public class CustomFieldHttpErrorService : Service
{
public object Any(CustomFieldHttpError request)
{
throw new HttpError(new CustomFieldHttpErrorResponse
{
Custom = "Ignored",
ResponseStatus = new ResponseStatus("StatusErrorCode", "StatusErrorMessage")
},
500,
"HeaderErrorCode");
}
}
}