| 
				
			 | 
			
			
				
				@@ -3,6 +3,7 @@ using System.Threading.Tasks; 
			 | 
		
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				
				 using Luticate2.Utils.Controllers; 
			 | 
		
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				
				 using Luticate2.Utils.Dbo.Basic; 
			 | 
		
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				
				 using Microsoft.AspNetCore.Http; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				6
			 | 
			
			
				
				+using Microsoft.Extensions.Logging; 
			 | 
		
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				
				 using Newtonsoft.Json; 
			 | 
		
		
	
		
			
			| 
				7
			 | 
			
				8
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				8
			 | 
			
				9
			 | 
			
			
				
				 namespace Luticate2.Utils.Middlewares 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -10,10 +11,12 @@ namespace Luticate2.Utils.Middlewares 
			 | 
		
		
	
		
			
			| 
				10
			 | 
			
				11
			 | 
			
			
				
				     public class LuExceptionMiddleware 
			 | 
		
		
	
		
			
			| 
				11
			 | 
			
				12
			 | 
			
			
				
				     { 
			 | 
		
		
	
		
			
			| 
				12
			 | 
			
				13
			 | 
			
			
				
				         private readonly RequestDelegate _next; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				14
			 | 
			
			
				
				+        private readonly ILogger<LuExceptionMiddleware> _logger; 
			 | 
		
		
	
		
			
			| 
				13
			 | 
			
				15
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				14
			 | 
			
				
			 | 
			
			
				
				-        public LuExceptionMiddleware(RequestDelegate next) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				
				+        public LuExceptionMiddleware(RequestDelegate next, ILogger<LuExceptionMiddleware> logger) 
			 | 
		
		
	
		
			
			| 
				15
			 | 
			
				17
			 | 
			
			
				
				         { 
			 | 
		
		
	
		
			
			| 
				16
			 | 
			
				18
			 | 
			
			
				
				             _next = next; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				
				+            _logger = logger; 
			 | 
		
		
	
		
			
			| 
				17
			 | 
			
				20
			 | 
			
			
				
				         } 
			 | 
		
		
	
		
			
			| 
				18
			 | 
			
				21
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				19
			 | 
			
				22
			 | 
			
			
				
				         public async Task Invoke(HttpContext context) 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -24,6 +27,7 @@ namespace Luticate2.Utils.Middlewares 
			 | 
		
		
	
		
			
			| 
				24
			 | 
			
				27
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				25
			 | 
			
				28
			 | 
			
			
				
				             catch (LuResultException e) 
			 | 
		
		
	
		
			
			| 
				26
			 | 
			
				29
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				
				+                _logger.LogError(e.Result.PrivateDetails + "\n" + e.Result.PublicDetails + "\n" + e.StackTrace); 
			 | 
		
		
	
		
			
			| 
				27
			 | 
			
				31
			 | 
			
			
				
				                 var response = context.Response; 
			 | 
		
		
	
		
			
			| 
				28
			 | 
			
				32
			 | 
			
			
				
				                 response.ContentType = "application/json"; 
			 | 
		
		
	
		
			
			| 
				29
			 | 
			
				33
			 | 
			
			
				
				                 response.StatusCode = e.Result.GetHttpCode(); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -35,8 +39,9 @@ namespace Luticate2.Utils.Middlewares 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				39
			 | 
			
			
				
				                     Version = LuUtilsExtensions.Options.Version 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				40
			 | 
			
			
				
				                 })).ConfigureAwait(false); 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				41
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				
				-            catch (Exception e)//TODO 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				
				+            catch (Exception e) 
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				43
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				
				+                _logger.LogError(e.ToString()); 
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				45
			 | 
			
			
				
				                 var response = context.Response; 
			 | 
		
		
	
		
			
			| 
				41
			 | 
			
				46
			 | 
			
			
				
				                 response.ContentType = "application/json"; 
			 | 
		
		
	
		
			
			| 
				42
			 | 
			
				47
			 | 
			
			
				
				                 response.StatusCode = 500; 
			 |