26
26
using System . Threading ;
27
27
using System . Xml . Xsl ;
28
28
using System . Xml ;
29
- using System . Runtime . CompilerServices ;
30
29
using System . Reflection ;
31
30
32
31
namespace Microsoft . OpenApi . Hidi
@@ -36,7 +35,7 @@ public class OpenApiService
36
35
/// <summary>
37
36
/// Implementation of the transform command
38
37
/// </summary>
39
- public static async Task < int > TransformOpenApiDocument (
38
+ public static async Task TransformOpenApiDocument (
40
39
string openapi ,
41
40
string csdl ,
42
41
string csdlFilter ,
@@ -54,8 +53,7 @@ public static async Task<int> TransformOpenApiDocument(
54
53
CancellationToken cancellationToken
55
54
)
56
55
{
57
- using var loggerFactory = ConfigureLoggerInstance ( loglevel ) ;
58
- var logger = loggerFactory . CreateLogger < OpenApiService > ( ) ;
56
+ var logger = Logger . ConfigureLogger ( loglevel ) ;
59
57
60
58
try
61
59
{
@@ -212,18 +210,11 @@ CancellationToken cancellationToken
212
210
logger . LogTrace ( $ "Finished serializing in { stopwatch . ElapsedMilliseconds } ms") ;
213
211
textWriter . Flush ( ) ;
214
212
}
215
- return 0 ;
216
213
}
217
214
catch ( Exception ex )
218
215
{
219
- #if DEBUG
220
- logger . LogCritical ( ex , ex . Message ) ;
221
- #else
222
- logger . LogCritical ( ex . Message ) ;
223
-
224
- #endif
225
- return 1 ;
226
- }
216
+ throw new InvalidOperationException ( $ "Could not transform the document, reason: { ex . Message } ", ex ) ;
217
+ }
227
218
}
228
219
229
220
private static XslCompiledTransform GetFilterTransform ( )
@@ -249,18 +240,15 @@ private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslC
249
240
return stream ;
250
241
}
251
242
252
-
253
-
254
243
/// <summary>
255
244
/// Implementation of the validate command
256
245
/// </summary>
257
- public static async Task < int > ValidateOpenApiDocument (
246
+ public static async Task ValidateOpenApiDocument (
258
247
string openapi ,
259
248
LogLevel loglevel ,
260
249
CancellationToken cancellationToken )
261
250
{
262
- using var loggerFactory = ConfigureLoggerInstance ( loglevel ) ;
263
- var logger = loggerFactory . CreateLogger < OpenApiService > ( ) ;
251
+ var logger = Logger . ConfigureLogger ( loglevel ) ;
264
252
265
253
try
266
254
{
@@ -308,19 +296,11 @@ public static async Task<int> ValidateOpenApiDocument(
308
296
logger . LogTrace ( "Finished walking through the OpenApi document. Generating a statistics report.." ) ;
309
297
logger . LogInformation ( statsVisitor . GetStatisticsReport ( ) ) ;
310
298
}
311
-
312
- return 0 ;
313
299
}
314
300
catch ( Exception ex )
315
301
{
316
- #if DEBUG
317
- logger . LogCritical ( ex , ex . Message ) ;
318
- #else
319
- logger . LogCritical ( ex . Message ) ;
320
- #endif
321
- return 1 ;
302
+ throw new InvalidOperationException ( $ "Could not validate the document, reason: { ex . Message } ", ex ) ;
322
303
}
323
-
324
304
}
325
305
326
306
/// <summary>
0 commit comments