diff --git a/datasette/views/base.py b/datasette/views/base.py index eee7434e8e..0ccf3c9c4b 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -342,7 +342,7 @@ async def get(self, request): 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 8e08c3b1fb..964561a9e4 100644 --- a/datasette/views/database.py +++ b/datasette/views/database.py @@ -37,7 +37,7 @@ async def data(self, request, default_labels=False, _size=None): 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 @@ async def data( 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 cdbf0990f5..4d317470e9 100644 --- a/datasette/views/row.py +++ b/datasette/views/row.py @@ -19,7 +19,7 @@ async def data(self, request, default_labels=False): 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 @@ async def data(self, request, default_labels=False): 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 d479fedeea..4c50664cbc 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -96,7 +96,7 @@ async def post(self, request): 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 @@ async def _data_traced( 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 @@ async def gather(*args): # 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 0db0443498..8e913983f3 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 8e37468f39..ae911d8e28 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):