Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

4. Scoped Calls

Fatih Kılıç edited this page May 5, 2019 · 2 revisions

What Is Scoped calls?

Scoped calls are functions passed by user to use try and except for unexpected errors. Scoped calls runs after _filter_request and before _filter_response

Example

from anyapi import AnyAPI


def some_unexpected_error_handler(request):
    try:
        return request()
    except SomeUnexpectedError:
        pass

def other_unexpected_error_handler(request):
    # something similar


api = AnyAPI(
    "https://httpbin.org",
    scoped_calls=[some_unexpected_error_handler, other_unexpected_error_handler],
)

Another good example is inside utils.py

Clone this wiki locally