Skip to content

Commit d273ce1

Browse files
author
Bart Koelman
committed
AV1210: Do not catch-all
1 parent af9206d commit d273ce1

File tree

6 files changed

+14
-0
lines changed

6 files changed

+14
-0
lines changed

src/JsonApiDotNetCore/AtomicOperations/OperationsProcessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ public virtual async Task<IList<OperationContainer>> ProcessAsync(IList<Operatio
8484

8585
throw;
8686
}
87+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
8788
catch (Exception exception)
89+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
8890
{
8991
throw new JsonApiException(new Error(HttpStatusCode.InternalServerError)
9092
{

src/JsonApiDotNetCore/Resources/ResourceFactory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ private static IIdentifiable InnerCreateInstance(Type type, IServiceProvider ser
4444
? (IIdentifiable)Activator.CreateInstance(type)
4545
: (IIdentifiable)ActivatorUtilities.CreateInstance(serviceProvider, type);
4646
}
47+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
4748
catch (Exception exception)
49+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
4850
{
4951
throw new InvalidOperationException(
5052
hasSingleConstructorWithoutParameters
@@ -77,7 +79,9 @@ public NewExpression CreateNewExpression(Type resourceType)
7779

7880
constructorArguments.Add(argumentExpression);
7981
}
82+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
8083
catch (Exception exception)
84+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
8185
{
8286
throw new InvalidOperationException(
8387
$"Failed to create an instance of '{resourceType.FullName}': Parameter '{constructorParameter.Name}' could not be resolved.",

src/JsonApiDotNetCore/Serialization/JsonApiReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public async Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
6464
{
6565
throw ToInvalidRequestBodyException(exception, body);
6666
}
67+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
6768
catch (Exception exception)
69+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
6870
{
6971
throw new InvalidRequestBodyException(null, null, body, exception);
7072
}

src/JsonApiDotNetCore/Serialization/JsonApiWriter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public async Task WriteAsync(OutputFormatterWriteContext context)
5353
{
5454
responseContent = SerializeResponse(context.Object, (HttpStatusCode)response.StatusCode);
5555
}
56+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
5657
catch (Exception exception)
58+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
5759
{
5860
ErrorDocument errorDocument = _exceptionHandler.HandleException(exception);
5961
responseContent = _serializer.Serialize(errorDocument);

src/JsonApiDotNetCore/TypeHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ public static object CreateInstance(Type type)
334334
{
335335
return Activator.CreateInstance(type);
336336
}
337+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
337338
catch (Exception exception)
339+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
338340
{
339341
throw new InvalidOperationException($"Failed to create an instance of '{type.FullName}' using its default constructor.", exception);
340342
}

test/TestBuildingBlocks/HttpResponseMessageExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ private static async Task<string> GetFormattedContentAsync(HttpResponseMessage r
5050
return JsonConvert.DeserializeObject<JObject>(text).ToString();
5151
}
5252
}
53+
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
5354
catch
55+
#pragma warning restore AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException
5456
{
5557
// ignored
5658
}

0 commit comments

Comments
 (0)