diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index 9b8968a7d..1ab952327 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -64,8 +64,8 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques try { objs = FilterUtility::GetFilterTargets(qd, params, user); } catch (const std::exception& ex) { - HttpUtility::SendJsonError(response, 400, - "Type/Filter was required but not provided or was invalid.", + HttpUtility::SendJsonError(response, 404, + "No objects found.", HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); return true; } diff --git a/lib/remote/deleteobjecthandler.cpp b/lib/remote/deleteobjecthandler.cpp index 0e9c39ad1..efdeb1fac 100644 --- a/lib/remote/deleteobjecthandler.cpp +++ b/lib/remote/deleteobjecthandler.cpp @@ -61,7 +61,16 @@ bool DeleteObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r params->Set(attr, request.RequestUrl->GetPath()[3]); } - std::vector objs = FilterUtility::GetFilterTargets(qd, params, user); + std::vector objs; + + try { + objs = FilterUtility::GetFilterTargets(qd, params, user); + } catch (const std::exception& ex) { + HttpUtility::SendJsonError(response, 404, + "No objects found.", + HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + return true; + } bool cascade = HttpUtility::GetLastParameter(params, "cascade"); diff --git a/lib/remote/modifyobjecthandler.cpp b/lib/remote/modifyobjecthandler.cpp index a91fdb336..f648a19f2 100644 --- a/lib/remote/modifyobjecthandler.cpp +++ b/lib/remote/modifyobjecthandler.cpp @@ -59,7 +59,16 @@ bool ModifyObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r params->Set(attr, request.RequestUrl->GetPath()[3]); } - std::vector objs = FilterUtility::GetFilterTargets(qd, params, user); + std::vector objs; + + try { + objs = FilterUtility::GetFilterTargets(qd, params, user); + } catch (const std::exception& ex) { + HttpUtility::SendJsonError(response, 404, + "No objects found.", + HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + return true; + } Dictionary::Ptr attrs = params->Get("attrs"); diff --git a/lib/remote/objectqueryhandler.cpp b/lib/remote/objectqueryhandler.cpp index e19d7f29c..ef6c937a4 100644 --- a/lib/remote/objectqueryhandler.cpp +++ b/lib/remote/objectqueryhandler.cpp @@ -142,7 +142,16 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re params->Set(attr, request.RequestUrl->GetPath()[3]); } - std::vector objs = FilterUtility::GetFilterTargets(qd, params, user); + std::vector objs; + + try { + objs = FilterUtility::GetFilterTargets(qd, params, user); + } catch (const std::exception& ex) { + HttpUtility::SendJsonError(response, 404, + "No objects found.", + HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + return true; + } Array::Ptr results = new Array(); results->Reserve(objs.size()); diff --git a/lib/remote/statushandler.cpp b/lib/remote/statushandler.cpp index 08a293ee0..cce71fbef 100644 --- a/lib/remote/statushandler.cpp +++ b/lib/remote/statushandler.cpp @@ -92,7 +92,16 @@ bool StatusHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request if (request.RequestUrl->GetPath().size() >= 3) params->Set("status", request.RequestUrl->GetPath()[2]); - std::vector objs = FilterUtility::GetFilterTargets(qd, params, user); + std::vector objs; + + try { + objs = FilterUtility::GetFilterTargets(qd, params, user); + } catch (const std::exception& ex) { + HttpUtility::SendJsonError(response, 404, + "No objects found.", + HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + return true; + } Array::Ptr results = Array::FromVector(objs); diff --git a/lib/remote/typequeryhandler.cpp b/lib/remote/typequeryhandler.cpp index 12931639e..ba8e5225c 100644 --- a/lib/remote/typequeryhandler.cpp +++ b/lib/remote/typequeryhandler.cpp @@ -97,7 +97,16 @@ bool TypeQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& requ if (request.RequestUrl->GetPath().size() >= 3) params->Set("name", request.RequestUrl->GetPath()[2]); - std::vector objs = FilterUtility::GetFilterTargets(qd, params, user); + std::vector objs; + + try { + objs = FilterUtility::GetFilterTargets(qd, params, user); + } catch (const std::exception& ex) { + HttpUtility::SendJsonError(response, 404, + "No objects found.", + HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : ""); + return true; + } Array::Ptr results = new Array();