public ActionResult Get()
        {
            IKnownException knownException;
            var             exceptionHandlerFeature = HttpContext.Features.Get <IExceptionHandlerFeature>();
            var             exception = exceptionHandlerFeature?.Error;

            if (exception is IKnownException ex)
            {
                knownException = ex;
            }
            else
            {
                //未知錯誤必須記錄log
                knownException = KnownException.UnKnow();
            }

            return(Content(knownException.ToString()));
        }
        public void OnException(ExceptionContext context)
        {
            var knowException = context.Exception as IKnownException;

            context.HttpContext.Response.StatusCode = StatusCodes.Status200OK;
            if (knowException == null)
            {
                // 紀錄log
                _logger.LogError(context.Exception.ToString());
                context.HttpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
                ;
                knowException = KnownException.UnKnow();
            }

            context.Result = new JsonResult(KnownException.FromKnownException(knowException))
            {
                ContentType = "application/json;charset=utf-8"
            };
        }