From 75c5e6f6b0ac13e51a726d0a0a0a4f32f96d523a Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 5 Apr 2018 17:17:30 +0200 Subject: [PATCH] Enhance error handling in config stages handler --- lib/remote/configstageshandler.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/remote/configstageshandler.cpp b/lib/remote/configstageshandler.cpp index c564a8a77..32d56e39e 100644 --- a/lib/remote/configstageshandler.cpp +++ b/lib/remote/configstageshandler.cpp @@ -59,10 +59,10 @@ void ConfigStagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& reque String stageName = HttpUtility::GetLastParameter(params, "stage"); if (!ConfigPackageUtility::ValidateName(packageName)) - return HttpUtility::SendJsonError(response, params, 400, "Invalid package name."); + return HttpUtility::SendJsonError(response, params, 400, "Invalid package name '" + packageName + "'."); if (!ConfigPackageUtility::ValidateName(stageName)) - return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name."); + return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name '" + stageName + "'."); ArrayData results; @@ -95,7 +95,7 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ String packageName = HttpUtility::GetLastParameter(params, "package"); if (!ConfigPackageUtility::ValidateName(packageName)) - return HttpUtility::SendJsonError(response, params, 400, "Invalid package name."); + return HttpUtility::SendJsonError(response, params, 400, "Invalid package name '" + packageName + "'."); bool reload = true; if (params->Contains("reload")) @@ -116,8 +116,8 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ ConfigPackageUtility::AsyncTryActivateStage(packageName, stageName, reload); } catch (const std::exception& ex) { return HttpUtility::SendJsonError(response, params, 500, - "Stage creation failed.", - HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + "Stage creation failed for '" + stageName + "'.", + DiagnosticInformation(ex, false)); } @@ -153,17 +153,17 @@ void ConfigStagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& re String stageName = HttpUtility::GetLastParameter(params, "stage"); if (!ConfigPackageUtility::ValidateName(packageName)) - return HttpUtility::SendJsonError(response, params, 400, "Invalid package name."); + return HttpUtility::SendJsonError(response, params, 400, "Invalid package name '" + packageName + "'."); if (!ConfigPackageUtility::ValidateName(stageName)) - return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name."); + return HttpUtility::SendJsonError(response, params, 400, "Invalid stage name '" + stageName + "'."); try { ConfigPackageUtility::DeleteStage(packageName, stageName); } catch (const std::exception& ex) { return HttpUtility::SendJsonError(response, params, 500, - "Failed to delete stage.", - HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + "Failed to delete stage '" + stageName + "' in package '" + packageName + "'.", + DiagnosticInformation(ex, false)); } Dictionary::Ptr result1 = new Dictionary({ -- 2.40.0