* Executes the DSL script via HTTP and returns HTTP and user errors. * * @param session Local session handler. * @param command The DSL string. * @param sandboxed Whether to run this sandboxed. * @return Result value, also contains user errors. */
| 641 | * @return Result value, also contains user errors. |
| 642 | */ |
| 643 | Value ConsoleCommand::ExecuteScript(const String& session, const String& command, bool sandboxed) |
| 644 | { |
| 645 | /* Extend the url parameters for the request. */ |
| 646 | l_Url->SetPath({"v1", "console", "execute-script"}); |
| 647 | |
| 648 | l_Url->SetQuery({ |
| 649 | {"session", session}, |
| 650 | {"command", command}, |
| 651 | {"sandboxed", sandboxed ? "1" : "0"} |
| 652 | }); |
| 653 | |
| 654 | Dictionary::Ptr jsonResponse = SendRequest(); |
| 655 | |
| 656 | /* Extract the result, and handle user input errors too. */ |
| 657 | Array::Ptr results = jsonResponse->Get("results"); |
| 658 | Value result; |
| 659 | |
| 660 | if (results && results->GetLength() > 0) { |
| 661 | Dictionary::Ptr resultInfo = results->Get(0); |
| 662 | |
| 663 | if (resultInfo->Get("code") >= 200 && resultInfo->Get("code") <= 299) { |
| 664 | result = resultInfo->Get("result"); |
| 665 | } else { |
| 666 | String errorMessage = resultInfo->Get("status"); |
| 667 | |
| 668 | DebugInfo di; |
| 669 | Dictionary::Ptr debugInfo = resultInfo->Get("debug_info"); |
| 670 | |
| 671 | if (debugInfo) { |
| 672 | di.Path = debugInfo->Get("path"); |
| 673 | di.FirstLine = debugInfo->Get("first_line"); |
| 674 | di.FirstColumn = debugInfo->Get("first_column"); |
| 675 | di.LastLine = debugInfo->Get("last_line"); |
| 676 | di.LastColumn = debugInfo->Get("last_column"); |
| 677 | } |
| 678 | |
| 679 | bool incompleteExpression = resultInfo->Get("incomplete_expression"); |
| 680 | BOOST_THROW_EXCEPTION(ScriptError(errorMessage, di, incompleteExpression)); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | return result; |
| 685 | } |
| 686 | |
| 687 | /** |
| 688 | * Executes the auto completion script via HTTP and returns HTTP and user errors. |
nothing calls this directly
no test coverage detected