@@ -4,7 +4,7 @@ public static class ProblemDetailsHelper
44{
55 public static void AddDefaultExtensionsFromContext ( this BaseDetails details ,
66 ActionContext context ,
7- List < ErrorDetail > errors = null )
7+ List < ErrorDetail > ? errors = null )
88 {
99 foreach ( var ( key , value ) in GetExtensionsFromContext ( context , errors ) )
1010 {
@@ -14,7 +14,7 @@ public static void AddDefaultExtensionsFromContext(this BaseDetails details,
1414
1515 public static void AddDefaultExtensionsFromContext ( this BaseDetails details ,
1616 ExceptionContext context ,
17- List < ErrorDetail > errors = null )
17+ List < ErrorDetail > ? errors = null )
1818 {
1919 foreach ( var ( key , value ) in GetExtensionsFromContext ( context , errors ) )
2020 {
@@ -23,12 +23,12 @@ public static void AddDefaultExtensionsFromContext(this BaseDetails details,
2323 }
2424
2525 private static IDictionary < string , object > GetExtensionsFromContext ( ActionContext context ,
26- List < ErrorDetail > errors = null )
26+ List < ErrorDetail > ? errors = null )
2727 {
2828 var dictionary = new Dictionary < string , object >
2929 {
3030 { "Method" , context . HttpContext . Request . Method } ,
31- { "QueryString" , context . HttpContext . Request . QueryString . Value } ,
31+ { "QueryString" , context . HttpContext . Request . QueryString . Value ?? string . Empty } ,
3232 { "CorrelationId" , context . HttpContext . Request . Headers [ "x-correlation-id" ] . ToString ( ) } ,
3333 { "TraceId" , context . HttpContext . TraceIdentifier }
3434 } ;
@@ -39,12 +39,12 @@ private static IDictionary<string, object> GetExtensionsFromContext(ActionContex
3939 }
4040
4141 private static IDictionary < string , object > GetExtensionsFromContext ( ExceptionContext context ,
42- List < ErrorDetail > errors = null )
42+ List < ErrorDetail > ? errors = null )
4343 {
4444 var dictionary = new Dictionary < string , object >
4545 {
4646 { "Method" , context . HttpContext . Request . Method } ,
47- { "QueryString" , context . HttpContext . Request . QueryString . Value } ,
47+ { "QueryString" , context . HttpContext . Request . QueryString . Value ?? string . Empty } ,
4848 { "CorrelationId" , context . HttpContext . Request . Headers [ "x-correlation-id" ] . ToString ( ) } ,
4949 { "TraceId" , context . HttpContext . TraceIdentifier }
5050 } ;
@@ -54,22 +54,15 @@ private static IDictionary<string, object> GetExtensionsFromContext(ExceptionCon
5454 return dictionary ;
5555 }
5656
57- public static ConstructorInfo GetActionContextConstructor < T > ( )
57+ public static ConstructorInfo ? GetActionContextConstructor < T > ( )
5858 where T : BaseDetails
5959 {
60- try
60+ return typeof ( T ) . GetConstructor ( new [ ]
6161 {
62- return typeof ( T ) . GetConstructor ( new [ ]
63- {
64- typeof ( ActionContext ) ,
65- typeof ( string ) ,
66- typeof ( string ) ,
67- typeof ( List < ErrorDetail > )
68- } ) ;
69- }
70- catch ( Exception e )
71- {
72- throw new Exception ( $ "Error creating constructor for type: { typeof ( T ) } ", e ) ;
73- }
62+ typeof ( ActionContext ) ,
63+ typeof ( string ) ,
64+ typeof ( string ) ,
65+ typeof ( List < ErrorDetail > )
66+ } ) ;
7467 }
7568}
0 commit comments