Skip to content

Add docs about errors in enum #44

@sobolevn

Description

@sobolevn

It is a common practice to put possible errors in enum (or Sum Type).

So, we can later use them like so:

from enum import Enum, unique

@unique
class APIExceptions(Enum):
      _value: Exception 
      ServerTimeoutError = exceptions.ServerTimeoutError
      OtherError = exceptions.OtherError

def call_api() -> Result[int, APIExceptions]: ... 

We can also try Union and not enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions