Git Product home page Git Product logo

Comments (5)

leirons avatar leirons commented on June 29, 2024

Think it's a good idea

from pyee.

jfhbrook avatar jfhbrook commented on June 29, 2024

what about:

Args = TypeVar(name="Args")
Kwargs = TypeVar(name="Kwargs")


@dataclass
class CoroError(PyeeError, Generic[Args, Kwargs]):
    exc: Exception
    handler: CoroHandler
    args: Args
    kwargs: Kwargs

    
def _emit_run(self, f: CoroHandler, args: Iterable[Args], kwargs: Dict[str, Kwargs]):
    try:
        coro = f(*args, **kwargs)
    except Exception as exc:
        self.emit("error",CoroError(exc=exc,handler=f,args=args, kwargs=kwargs)

from pyee.

leirons avatar leirons commented on June 29, 2024

what about:

@dataclass
class AsyncIOPyeeError(PyeeError):
    exc: Exception
    handler: CoroHandler
    args: Tuple[Any,...]
    kwargs: Dict[str, Any]

    
def _emit_run(self, f: CoroHandler, args: Iterable[Args], kwargs: Dict[str, Kwargs]):
    try:
        coro = f(*args, **kwargs)
    except Exception as exc:
        self.emit("error", AsyncIOPyeeError(exc=exc,handler=f,args=args, kwargs=kwargs)

Looks good, but i dont know why you need to use Protocol, didnt see it in other projects and dont know how it's works, but i will check it

from pyee.

jfhbrook avatar jfhbrook commented on June 29, 2024

Protocol might be a red herring, you can probably substitute Generic[Args, Kwargs] instead. If you're not familiar with type annotations you can safely ignore them.

from pyee.

jfhbrook avatar jfhbrook commented on June 29, 2024

I took these notes and captured a plan for potential feature work in #102. In the meantime, I don't have any great answers aside from capturing Exceptions at the top of your handler "manually".

Thanks!

from pyee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.