public async Task <IActionResult> CheckScriptInputAsync(ScriptExerciseInputData inputData) { try { ViewData["LastScriptInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckScriptInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.Input)) { AddStatusMessage(_localizer["CheckScriptInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckScriptInputAsync:Success"], StatusMessageTypes.Success); return(await RenderAsync()); } catch (Exception ex) { _logger.LogError(ex, "Check script input"); AddStatusMessage(_localizer["CheckScriptInputAsync:UnknownError"], StatusMessageTypes.Error); return(await RenderAsync()); } }
public async Task <IActionResult> CheckScriptInputAsync(ScriptExerciseInputData inputData) { try { ViewData["LastScriptInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckScriptInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.Input)) { AddStatusMessage(_localizer["CheckScriptInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckScriptInputAsync: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 script input"); AddStatusMessage(_localizer["CheckScriptInputAsync: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()); } }