File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed
src/IntelOrca.Biohazard.BioRand.Common Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 3
3
<TargetFramework >netstandard2.0</TargetFramework >
4
4
<Nullable >enable</Nullable >
5
5
<LangVersion >12.0</LangVersion >
6
- <Version >1.0 .0</Version >
6
+ <Version >1.1 .0</Version >
7
7
<Title >BioRand Common Library</Title >
8
8
<Authors >Ted John</Authors >
9
9
<Product >$(AssemblyName)</Product >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Net . Http ;
3
+ using System . Text ;
4
+ using System . Text . Json ;
5
+ using System . Threading ;
6
+ using System . Threading . Tasks ;
7
+
1
8
namespace IntelOrca . Biohazard . BioRand
2
9
{
3
10
public class RandomizerAgent
@@ -43,10 +50,16 @@ public async Task RunAsync(CancellationToken ct = default)
43
50
{
44
51
if ( await RegisterAsync ( ) )
45
52
{
46
- await Task . WhenAny (
47
- RunStatusLoopAsync ( ct ) ,
48
- RunProcessLoopAsync ( ct ) ) ;
49
- await UnregisterAsync ( ) ;
53
+ try
54
+ {
55
+ await Task . WhenAny (
56
+ RunStatusLoopAsync ( ct ) ,
57
+ RunProcessLoopAsync ( ct ) ) ;
58
+ }
59
+ finally
60
+ {
61
+ await UnregisterAsync ( ) ;
62
+ }
50
63
}
51
64
await Task . Delay ( RestartTime , ct ) ;
52
65
}
@@ -225,10 +238,12 @@ private async Task GenerateRandomizer(QueueResponseItem q)
225
238
}
226
239
catch ( Exception ex )
227
240
{
241
+ var reason = ex is RandomizerUserException ue ? ue . Message : "An internal error occured generating the randomizer." ;
228
242
await PostAsync < object > ( "generator/fail" , new
229
243
{
230
244
Id ,
231
- RandoId = q . Id
245
+ RandoId = q . Id ,
246
+ Reason = reason
232
247
} ) ;
233
248
_handler . LogError ( ex , "Failed to generate randomizer" ) ;
234
249
return ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ namespace IntelOrca . Biohazard . BioRand
4
+ {
5
+ public class RandomizerUserException ( string reason ) : Exception ( reason )
6
+ {
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments