diff --git a/datasette/app.py b/datasette/app.py index f732f95c..001cf4c3 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1628,9 +1628,7 @@ class Datasette: if not table_exists: is_view = await db.view_exists(table_name) if not (table_exists or is_view): - raise TableNotFound( - "Table not found: {}".format(table_name), db.name, table_name - ) + raise TableNotFound(db.name, table_name) return ResolvedTable(db, table_name, is_view) async def resolve_row(self, request): diff --git a/datasette/utils/asgi.py b/datasette/utils/asgi.py index b3f00bb3..6bdba714 100644 --- a/datasette/utils/asgi.py +++ b/datasette/utils/asgi.py @@ -29,8 +29,8 @@ class DatabaseNotFound(NotFound): class TableNotFound(NotFound): - def __init__(self, message, database_name, table): - super().__init__(message) + def __init__(self, database_name, table): + super().__init__("Table not found") self.database_name = database_name self.table = table diff --git a/tests/test_api_write.py b/tests/test_api_write.py index 2cd87858..94eb902b 100644 --- a/tests/test_api_write.py +++ b/tests/test_api_write.py @@ -140,7 +140,7 @@ async def test_insert_rows(ds_write, return_rows): {}, None, 404, - ["Table not found: docs2"], + ["Table not found"], ), ( "/data/docs/-/insert", @@ -274,7 +274,7 @@ async def test_insert_rows(ds_write, return_rows): {"rows": [{"title": "Test"}]}, None, 404, - ["Table not found: badtable"], + ["Table not found"], ), # missing primary key ( @@ -598,7 +598,7 @@ async def test_delete_row_errors(ds_write, scenario): assert ( response.json()["errors"] == ["Permission denied"] if scenario == "no_token" - else ["Table not found: bad_table"] + else ["Table not found"] ) assert len((await ds_write.client.get("/data/docs.json?_shape=array")).json()) == 1 @@ -703,7 +703,7 @@ async def test_update_row_check_permission(ds_write, scenario): assert ( response.json()["errors"] == ["Permission denied"] if scenario == "no_token" - else ["Table not found: bad_table"] + else ["Table not found"] ) @@ -830,7 +830,7 @@ async def test_drop_table(ds_write, scenario): assert response.json()["ok"] is False expected_error = "Permission denied" if scenario == "bad_table": - expected_error = "Table not found: bad_table" + expected_error = "Table not found" elif scenario == "immutable": expected_error = "Database is immutable" assert response.json()["errors"] == [expected_error] diff --git a/tests/test_table_api.py b/tests/test_table_api.py index 58930950..8360157d 100644 --- a/tests/test_table_api.py +++ b/tests/test_table_api.py @@ -36,7 +36,7 @@ async def test_table_json(ds_client): async def test_table_not_exists_json(ds_client): assert (await ds_client.get("/fixtures/blah.json")).json() == { "ok": False, - "error": "Table not found: blah", + "error": "Table not found", "status": 404, "title": None, } diff --git a/tests/test_table_html.py b/tests/test_table_html.py index fcf914a6..1a9ed540 100644 --- a/tests/test_table_html.py +++ b/tests/test_table_html.py @@ -535,7 +535,7 @@ async def test_csv_json_export_links_include_labels_if_foreign_keys(ds_client): @pytest.mark.asyncio async def test_table_not_exists(ds_client): - assert "Table not found: blah" in (await ds_client.get("/fixtures/blah")).text + assert "Table not found" in (await ds_client.get("/fixtures/blah")).text @pytest.mark.asyncio