Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Promptflow CLI] Write exception info to stderr when set env PROMPTFL…
…OW_STRUCTURE_EXCEPTION_OUTPUT (#331) # Description Write exception info and command to stderr when set environment variable `PROMPTFLOW_STRUCTURE_EXCEPTION_OUTPUT=true` ![image](https://github.com/microsoft/promptflow/assets/17938940/8c3f21ce-b62d-46cb-b7a9-a2e6de3337b3) promptflow error in stderr: ``` json { "message":"Connection 'invalid_name' is not found.", "messageFormat":"", "messageParameters":{ }, "referenceCode":"Unknown", "code":"ConnectionNotFoundError", "innerError":null, "debugInfo":{ "type":"ConnectionNotFoundError", "message":"Connection 'invalid_name' is not found.", "stackTrace":"Traceback (most recent call last):\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_utils.py\", line 354, in wrapper\n return func(*args, **kwargs)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_pf\\_connection.py\", line 187, in show_connection\n connection = _client.connections.get(name)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\operations\\_connection_operations.py\", line 47, in get\n orm_connection = ORMConnection.get(name, raise_error)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\_orm\\retry.py\", line 43, in f_retry\n return f(*args, **kwargs)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\_orm\\connection.py\", line 52, in get\n raise ConnectionNotFoundError(f\"Connection {name!r} is not found.\")\n", "innerException":null }, "command":"pf connection show --name invalid_name --format_exception" } ``` system error in stderr: ``` json { "code":"SystemError", "message":"mock exception", "messageFormat":"", "messageParameters":{ }, "innerError":{ "code":"Exception", "innerError":null }, "debugInfo":{ "type":"Exception", "message":"mock exception", "stackTrace":"Traceback (most recent call last):\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_utils.py\", line 354, in wrapper\n return func(*args, **kwargs)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_pf\\_connection.py\", line 187, in show_connection\n connection = _client.connections.get(name)\n File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1093, in __call__\n return self._mock_call(*args, **kwargs)\n File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1097, in _mock_call\n return self._execute_mock_call(*args, **kwargs)\n File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1158, in _execute_mock_call\n result = effect(*args, **kwargs)\n File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\tests\\sdk_cli_test\\e2etests\\test_cli.py\", line 1123, in mocked_connection_get\n raise Exception(\"mock exception\")\n", "innerException":null }, "command":"pf connection show --name invalid_connection_name --format_exception" } ``` # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes]** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [x] Pull request includes test coverage for the included changes.
- Loading branch information