-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using AElf.ExceptionHandler; | ||
|
||
namespace EoaServer; | ||
|
||
|
||
public class HandlerExceptionService | ||
{ | ||
public static async Task<FlowBehavior> HandleWithReturn(Exception ex) | ||
Check warning on line 11 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.Silo)
Check warning on line 11 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.EntityEventHandler)
Check warning on line 11 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.AuthServer)
Check warning on line 11 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.HttpApi.Host)
|
||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Return, | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithContinue(Exception ex) | ||
Check warning on line 19 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.Silo)
Check warning on line 19 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.EntityEventHandler)
Check warning on line 19 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.AuthServer)
Check warning on line 19 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.HttpApi.Host)
|
||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Continue, | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithReturnNull(Exception ex) | ||
Check warning on line 27 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.Silo)
Check warning on line 27 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.EntityEventHandler)
Check warning on line 27 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.AuthServer)
Check warning on line 27 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.HttpApi.Host)
|
||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Return, | ||
ReturnValue = null | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithReThrow(Exception ex) | ||
Check warning on line 36 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.Silo)
Check warning on line 36 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.EntityEventHandler)
Check warning on line 36 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.AuthServer)
Check warning on line 36 in src/EoaServer.Application.Contracts/HandlerExceptionService.cs GitHub Actions / publish (EoaServer.HttpApi.Host)
|
||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Rethrow | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithHttpException(Exception ex) | ||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Throw, | ||
ReturnValue = new HttpRequestException(ex.Message) | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithReturnMinusOne(Exception ex) | ||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Return, | ||
ReturnValue = -1 | ||
}; | ||
} | ||
|
||
public static async Task<FlowBehavior> HandleWithReturnLongMinusOne(Exception ex) | ||
{ | ||
return new FlowBehavior | ||
{ | ||
ExceptionHandlingStrategy = ExceptionHandlingStrategy.Return, | ||
ReturnValue = -1L | ||
}; | ||
} | ||
} |