Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ __pycache__

# Generated code
/stubs/
/fastly_compute/exceptions/*
!/fastly_compute/exceptions/__init__.py
/fastly_compute/runtime_patching/patches.py

# Build artifacts
/build/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $(BUILD_DIR)/%.composed.wasm: wit/viceroy.wit wit/deps/fastly/compute.wit fastly
# The script that writes the exceptions and the patches always rewrites
# everything, so we can depend on the mod date of only 1 file. We choose
# patches.py, because its name doesn't depend on the WIT contents.
fastly_compute/runtime_patching/patches.py: scripts/generate_patches/*.py $(COMPUTE_WIT)
fastly_compute/runtime_patching/patches.py: scripts/generate_patches/*.py $(shell find scripts/generate_patches/templates -name "*.jinja") $(COMPUTE_WIT)
uv run python -m scripts.generate_patches

# Create build directory
Expand Down
5 changes: 4 additions & 1 deletion examples/backend-requests/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/bottle-app/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/flask-app/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/game-of-life/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions fastly_compute/exceptions/acl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Blocklists using [Access Control Lists] (ACLs)

[Access Control Lists]: https://www.fastly.com/documentation/reference/api/acls/
"""
23 changes: 23 additions & 0 deletions fastly_compute/exceptions/acl/acl_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""Errors returned on ACL lookup failure."""

from fastly_compute.exceptions import FastlyError


class AclError(FastlyError):
"""Errors returned on ACL lookup failure."""


class TooManyRequests(AclError):
"""Too many requests have been made.

This corresponds to an HTTP error code of 429, “Too Many Requests”.
"""


class GenericError(AclError):
"""Generic error value.

This means that some unexpected error occurred.
"""
1 change: 1 addition & 0 deletions fastly_compute/exceptions/http_body/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""HTTP bodies."""
21 changes: 21 additions & 0 deletions fastly_compute/exceptions/http_body/trailer_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""Trailers aren't available until the body has been completely transmitted, so this error
type can either indicate that the errors aren't available yet, or that an error occurred.
"""

from fastly_compute.exceptions import FastlyError


class TrailerError(FastlyError):
"""Trailers aren't available until the body has been completely transmitted, so this error
type can either indicate that the errors aren't available yet, or that an error occurred.
"""


class NotAvailableYet(TrailerError):
"""The trailers aren't available yet."""


class Error(TrailerError):
"""An error occurred."""
9 changes: 9 additions & 0 deletions fastly_compute/exceptions/http_req/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""An `error` code, optionally with extra request error information."""

from fastly_compute.exceptions import FastlyError


class ErrorWithDetail(FastlyError):
"""An `error` code, optionally with extra request error information."""
7 changes: 7 additions & 0 deletions fastly_compute/exceptions/kv_store/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Interface to Fastly's [Compute KV Store].

For a high-level introduction to this feature, see this [blog post].

[Compute KV Store]: https://www.fastly.com/documentation/guides/concepts/edge-state/data-stores/#kv-stores
[blog post]: https://www.fastly.com/blog/introducing-the-compute-edge-kv-store-global-persistent-storage-for-compute-functions
"""
57 changes: 57 additions & 0 deletions fastly_compute/exceptions/kv_store/kv_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""A value indicating the status of a KV store operation."""

from fastly_compute.exceptions import FastlyError


class KvError(FastlyError):
"""A value indicating the status of a KV store operation."""


class BadRequest(KvError):
"""KV store cannot or will not process the request due to something that is perceived to be a
client error.

This will map to the api's 400 codes.
"""


class PreconditionFailed(KvError):
"""KV store cannot fulfill the request, as defined by the client's prerequisites, for example
`if-generation-match`.

This will map to the api's 412 codes.
"""


class PayloadTooLarge(KvError):
"""The size limit for a KV store key was exceeded.

This will map to the api's 413 codes.
"""


class InternalError(KvError):
"""The system encountered an unexpected internal error.

This will map to all remaining http error codes.
"""


class TooManyRequests(KvError):
"""Too many requests have been made to the KV store.

This will map to the api's 429 codes.
"""


class GenericError(KvError):
"""Generic error value.

This means that some unexpected error occurred.
"""


class Extra(KvError):
"""Additional error information may be added in the future via this resource type."""
1 change: 1 addition & 0 deletions fastly_compute/exceptions/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Types used by many interfaces in this package."""
116 changes: 116 additions & 0 deletions fastly_compute/exceptions/types/error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""A common error type used by many functions in this package.

TODO: In the future this should be split up into more-specific error
enums so that it better documents which errors each function can actually
return and what they mean.
"""

from fastly_compute.exceptions import FastlyError


class Error(FastlyError):
"""A common error type used by many functions in this package.

TODO: In the future this should be split up into more-specific error
enums so that it better documents which errors each function can actually
return and what they mean.
"""


class GenericError(Error):
"""Generic error value.

This means that some unexpected error occurred.
"""


class InvalidArgument(Error):
"""Invalid argument."""


class AuxiliaryError(Error):
"""Auxiliary error value.

For `cache.get-body` and `cache.replace-get-body`, it means the cache implementation was
busy and not ready to retrieve the body data.

For cache APIs that attempt to write to or update the body of a cache transaction, it means
that an error occurred while attempting the write or update.

For other cache APIs, it indicates that the underlying cache entry or cache replace entry
is no longer available.

For writing to a streaming HTTP body, indicates that the body has already been closed.

For a dictionary lookup, indicates that the dictionary was not found.
"""


class Unsupported(Error):
"""Unsupported operation error.

This error is returned when some operation cannot be performed, because it is not supported.
"""


class HttpInvalid(Error):
"""Invalid HTTP error.

This can be returned when a method, URI, header, or status is not valid. This can also
be returned if a message head is too large.
"""


class HttpUser(Error):
"""HTTP user error.

This is returned in cases where user code caused an HTTP error. For example, attempt to send
a 1xx response code, or a request with a non-absolute URI. This can also be caused by
an unexpected header: both `content-length` and `transfer-encoding`, for example.
"""


class HttpIncomplete(Error):
"""HTTP incomplete message error.

This can be returned when a stream ended unexpectedly.
"""


class CannotRead(Error):
"""Cannot read.

An error occurred while attempting to read the body of a cache transaction.
"""


class HttpHeadTooLarge(Error):
"""Message head too large."""


class HttpInvalidStatus(Error):
"""Invalid HTTP status."""


class LimitExceeded(Error):
"""Limit exceeded

This is returned when an attempt to allocate a resource has exceeded the maximum number of
resources permitted. For example, creating too many response handles.
"""


class BufferLen(Error):
"""Buffer length error

Returned when a buffer is the wrong size.
Includes the buffer length that would allow the operation to succeed.
"""

def __init__(self, wit_error):
self.length = wit_error.value

def __str__(self):
return f"Buffer was too short to hold the result. At least {self.length} bytes are needed."
47 changes: 47 additions & 0 deletions fastly_compute/exceptions/types/open_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is automatically generated by generate_patches.
# It is not intended for manual editing.
"""An error returned by `open`-like functions."""

from fastly_compute.exceptions import FastlyError


class OpenError(FastlyError):
"""An error returned by `open`-like functions."""


class InvalidSyntax(OpenError):
"""The given name of the entity to open was invalid."""


class NameTooLong(OpenError):
"""The given name is longer the maximum permitted length."""


class Reserved(OpenError):
"""The given name is a reserved name that may not be opened."""


class NotFound(OpenError):
"""No entity by the given name was found."""


class Unsupported(OpenError):
"""Unsupported operation error.

This error is returned when some operation cannot be performed, because it is not supported.
"""


class LimitExceeded(OpenError):
"""Limit exceeded

This is returned when an attempt to allocate a resource has exceeded the maximum number of
resources permitted. For example, creating too many response handles.
"""


class GenericError(OpenError):
"""Generic error value.

This means that some unexpected error occurred.
"""
Loading
Loading