Refine error output if ErrorResponse received #279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looks like the resolution to this issue geldata/gel-cli#1125 is inside edgedb-rust (and edgedb itself).
This PR essentially changes this:
[2023-09-26T02:24:30Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 67305477[2023-09-26T02:24:30Z DEBUG edgedb_tokio::raw::connection] Error details: {257: b"Traceback (most recent call last):\n File "edb/server/dbview/dbview.pyx", line 1182, in edb.server.dbview.dbview.DatabaseIndex.get_db\nKeyError: 'edgedbb'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "edb/server/protocol/frontend.pyx", line 294, in edb.server.protocol.frontend.FrontendConnection.main\n File "edb/server/protocol/binary.pyx", line 1022, in authenticate\n File "edb/server/protocol/binary.pyx", line 292, in auth\n File "edb/server/protocol/binary.pyx", line 385, in _start_connection\n File "/home/edgedb/.local/share/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/server.py", line 621, in new_dbview\n db = self.get_db(dbname=dbname)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/edgedb/.local/share/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/server.py", line 614, in get_db\n return self._dbindex.get_db(dbname)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "edb/server/dbview/dbview.pyx", line 1184, in edb.server.dbview.dbview.DatabaseIndex.get_db\nedb.errors.UnknownDatabaseError: database 'edgedbb' does not exist\n"}
to this:
[2023-09-26T03:09:16Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 0x4030005
But also displays the extra output if RUST_LOG is set to at least debug.
The other part adding "please specify another one" that @1st1 mentions looks to be from here in the Python code: https://github.com/edgedb/edgedb/blob/23a7cd0f2db8d66addb0cd38950c85268f585742/edb/server/dbview/dbview.pyx#L1194 So maybe @msullivan might want to add that?
On a related point, when the CLI starts up it calls this log_levels::init() function here https://github.com/edgedb/edgedb-cli/blob/master/src/main.rs#L122 that does some pretty precise changes to the log levels depending on which command is being used and whether it's --verbose or not, so when I make a change to the CLI I always comment it out and set RUST_LOG to trace. It could be nice to make a flag to do this so everyday EdgeDB users and Rust users that don't feel like building the CLI just to see more debug output could set the log level to try to find out themselves what went wrong. Any reason not to add that flag in a different PR?