* Executes the auto completion script via HTTP and returns HTTP and user errors. * * @param session Local session handler. * @param command The auto completion string. * @param sandboxed Whether to run this sandboxed. * @return Result value, also contains user errors. */
| 693 | * @return Result value, also contains user errors. |
| 694 | */ |
| 695 | Array::Ptr ConsoleCommand::AutoCompleteScript(const String& session, const String& command, bool sandboxed) |
| 696 | { |
| 697 | /* Extend the url parameters for the request. */ |
| 698 | l_Url->SetPath({ "v1", "console", "auto-complete-script" }); |
| 699 | |
| 700 | l_Url->SetQuery({ |
| 701 | {"session", session}, |
| 702 | {"command", command}, |
| 703 | {"sandboxed", sandboxed ? "1" : "0"} |
| 704 | }); |
| 705 | |
| 706 | Dictionary::Ptr jsonResponse = SendRequest(); |
| 707 | |
| 708 | /* Extract the result, and handle user input errors too. */ |
| 709 | Array::Ptr results = jsonResponse->Get("results"); |
| 710 | Array::Ptr suggestions; |
| 711 | |
| 712 | if (results && results->GetLength() > 0) { |
| 713 | Dictionary::Ptr resultInfo = results->Get(0); |
| 714 | |
| 715 | if (resultInfo->Get("code") >= 200 && resultInfo->Get("code") <= 299) { |
| 716 | suggestions = resultInfo->Get("suggestions"); |
| 717 | } else { |
| 718 | String errorMessage = resultInfo->Get("status"); |
| 719 | BOOST_THROW_EXCEPTION(ScriptError(errorMessage)); |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | return suggestions; |
| 724 | } |
nothing calls this directly
no test coverage detected