Ejemplo n.º 1
0
 async def warpper(app: "Mirai"):
     try:
         return await func(app)
     except Exception as e:
         await self.queue.put(
             InternalEvent(name="UnexpectedException",
                           body=UnexpectedException(error=e,
                                                    event=None,
                                                    session=self)))
Ejemplo n.º 2
0
 async def throw_exception_event(self, event_context, queue, exception):
     if event_context.name != "UnexpectedException":
         #print("error: by pre:", event_context.name)
         await queue.put(
             InternalEvent(name="UnexpectedException",
                           body=UnexpectedException(error=exception,
                                                    event=event_context,
                                                    session=self)))
         EventLogger.error(
             f"threw a exception by {event_context.name}, Exception: {exception}"
         )
         traceback.print_exc()
     else:
         EventLogger.critical(
             f"threw a exception by {event_context.name}, Exception: {exception}, it's a exception handler."
         )
Ejemplo n.º 3
0
 async def put_exception(self, event_context, exception):
     from mirai.event.builtins import UnexpectedException
     if event_context.name != "UnexpectedException":
         if exception.__class__ in self.listening_exceptions:
             EventLogger.error(
                 f"threw a exception by {event_context.name}, Exception: {exception.__class__.__name__}, and it has been catched.")
         else:
             EventLogger.error(
                 f"threw a exception by {event_context.name}, Exception: {exception.__class__.__name__}, and it hasn't been catched!")
             traceback.print_exc()
         await self.queue.put(InternalEvent(
             name="UnexpectedException",
             body=UnexpectedException(
                 error=exception,
                 event=event_context,
                 application=self
             )
         ))
     else:
         EventLogger.critical(
             f"threw a exception in a exception handler by {event_context.name}, Exception: {exception.__class__.__name__}.")