diff --git a/datasette/views/base.py b/datasette/views/base.py index eee7434e..0ccf3c9c 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -342,7 +342,7 @@ class DataView(BaseView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database = db.name _format = request.url_vars["format"] diff --git a/datasette/views/database.py b/datasette/views/database.py index 8e08c3b1..964561a9 100644 --- a/datasette/views/database.py +++ b/datasette/views/database.py @@ -37,7 +37,7 @@ class DatabaseView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database = db.name visible, private = await self.ds.check_visibility( @@ -226,7 +226,7 @@ class QueryView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database = db.name params = {key: request.args.get(key) for key in request.args} if "sql" in params: diff --git a/datasette/views/row.py b/datasette/views/row.py index cdbf0990..4d317470 100644 --- a/datasette/views/row.py +++ b/datasette/views/row.py @@ -19,7 +19,7 @@ class RowView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database = db.name # Ensure user has permission to view this row @@ -38,14 +38,14 @@ class RowView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database = db.name sql, params, pks = await _sql_params_pks(db, table, pk_values) results = await db.execute(sql, params, truncate=True) columns = [r[0] for r in results.description] rows = list(results.rows) if not rows: - raise NotFound(f"Record not found: {pk_values}") + raise NotFound(f"Record not found") async def template_data(): display_columns, display_rows = await display_columns_and_rows( diff --git a/datasette/views/table.py b/datasette/views/table.py index d479fede..4c50664c 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -96,7 +96,7 @@ class TableView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database_name = db.name table_name = tilde_decode(request.url_vars["table"]) # Handle POST to a canned query @@ -169,7 +169,7 @@ class TableView(DataView): try: db = self.ds.get_database(route=database_route) except KeyError: - raise NotFound("Database not found: {}".format(database_route)) + raise NotFound("Database not found") database_name = db.name # We always now run queries sequentially, rather than with asyncio.gather() - @@ -204,7 +204,7 @@ class TableView(DataView): # If table or view not found, return 404 if not is_view and not table_exists: - raise NotFound(f"Table not found: {table_name}") + raise NotFound(f"Table not found") # Ensure user has permission to view this table visible, private = await self.ds.check_visibility( diff --git a/tests/test_table_api.py b/tests/test_table_api.py index 0db04434..8e913983 100644 --- a/tests/test_table_api.py +++ b/tests/test_table_api.py @@ -34,7 +34,7 @@ def test_table_json(app_client): def test_table_not_exists_json(app_client): assert { "ok": False, - "error": "Table not found: blah", + "error": "Table not found", "status": 404, "title": None, } == app_client.get("/fixtures/blah.json").json diff --git a/tests/test_table_html.py b/tests/test_table_html.py index 8e37468f..ae911d8e 100644 --- a/tests/test_table_html.py +++ b/tests/test_table_html.py @@ -520,7 +520,7 @@ def test_csv_json_export_links_include_labels_if_foreign_keys(app_client): def test_table_not_exists(app_client): - assert "Table not found: blah" in app_client.get("/fixtures/blah").text + assert "Table not found" in app_client.get("/fixtures/blah").text def test_table_html_no_primary_key(app_client):