public DataWrapperContext(IActionResult resultData, HttpContext httpContext, DataWrapperOptions options, ActionDescriptor actionDescriptor = null, ModelStateDictionary modelstate = null, SoftlyMiCakeException softlyMiCakeException = null) { ResultData = resultData; WrapperOptions = options; HttpContext = httpContext; ActionDescriptor = actionDescriptor; ModelState = modelstate; SoftlyException = softlyMiCakeException; }
private async Task WriteSoftExceptionResponse(HttpContext context, SoftlyMiCakeException softMiCakeException) { var httpResponse = context.Response; httpResponse.StatusCode = StatusCodes.Status200OK; var wrapDataResult = new ApiResponse(message: softMiCakeException.Message, result: softMiCakeException.Details) { ErrorCode = softMiCakeException.Code, IsError = true }; var options = new JsonSerializerOptions { WriteIndented = true, IgnoreNullValues = true, }; var resultJsonData = JsonSerializer.Serialize(wrapDataResult, options); await httpResponse.WriteAsync(resultJsonData); }