Skip to content

Bad app slug does not have a reasonable error message #53

@ry

Description

@ry
from deno_sandbox import DenoDeploy

sdk = DenoDeploy()

with open("main.js") as f:
  content = f.read()

app3A = sdk.apps.create(slug="app3A", layers=["demo-layer-3"])
print(app3A)

rev = sdk.revisions.deploy("app3A", {
  "main.js": { "content": content }
})
print(rev)

Here the slug "app3A" is invalid. However when running this program it results in this error message

# python create-apps.py
Traceback (most recent call last):
  File "/Users/ry/src/subhosting-demos/layers3/create-apps.py", line 10, in <module>
    app3A = sdk.apps.create(slug="app3A", layers=["demo-layer-3"])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ry/src/sandbox-py/src/deno_sandbox/apps.py", line 369, in create
    return self._bridge.run(
           ^^^^^^^^^^^^^^^^^
  File "/Users/ry/src/sandbox-py/src/deno_sandbox/bridge.py", line 27, in run
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.13/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.13/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/ry/src/sandbox-py/src/deno_sandbox/apps.py", line 248, in create
    result = await self._client.post("/api/v2/apps", options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ry/src/sandbox-py/src/deno_sandbox/console.py", line 149, in post
    response = await self._request("POST", req_url, data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ry/src/sandbox-py/src/deno_sandbox/console.py", line 144, in _request
    response.raise_for_status()
  File "/opt/homebrew/lib/python3.11/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://console.deno.com/api/v2/apps'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

It would be very nice to say more than just '400 Bad Request'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions