public async Task <IActionResult> CheckStringInputAsync(StringExerciseInputData inputData) { try { ViewData["LastStringInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckStringInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.Input)) { AddStatusMessage(_localizer["CheckStringInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckStringInputAsync:Success"], StatusMessageTypes.Success); return(await RenderAsync()); } catch (Exception ex) { _logger.LogError(ex, "Check string input"); AddStatusMessage(_localizer["CheckStringInputAsync:UnknownError"], StatusMessageTypes.Error); return(await RenderAsync()); } }
public async Task <IActionResult> CheckStringInputAsync(StringExerciseInputData inputData) { try { ViewData["LastStringInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckStringInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.Input)) { AddStatusMessage(_localizer["CheckStringInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckStringInputAsync:Success"], StatusMessageTypes.Success); return(await RenderAsync()); } catch (CtfApiException ex) { _logger.LogError(ex, "CTF error"); if (GetAdminMode()) { AddStatusMessage(_localizer["CtfError:Admin"], StatusMessageTypes.Error); AddStatusMessage(ex.FormattedResponseContent ?? "(none)", StatusMessageTypes.Info, true); } else { AddStatusMessage(_localizer["CtfError:Default"], StatusMessageTypes.Error); } return(await RenderAsync()); } catch (Exception ex) { _logger.LogError(ex, "Check string input"); AddStatusMessage(_localizer["CheckStringInputAsync:UnknownError"], StatusMessageTypes.Error); // Show more details for admins, so they can debug the issue if (GetAdminMode()) { AddStatusMessage(_localizer["ExceptionMessage", ex.Message], StatusMessageTypes.Info); } return(await RenderAsync()); } }