mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Update errorlimiter.py
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
from typing import final
|
||||
|
||||
|
||||
class ErrorLimiterTrigger(RuntimeError):
|
||||
def __init__(self, name: str, *args):
|
||||
super().__init__(*args)
|
||||
self.name = name
|
||||
|
||||
|
||||
class ErrorLimiterWarning(Exception):
|
||||
class ErrorLimiterError(Exception):
|
||||
def __init__(self, msg: str):
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
@final
|
||||
class ErrorLimiter:
|
||||
_store: dict[str, int] = {}
|
||||
|
||||
@@ -27,4 +23,4 @@ class ErrorLimiter:
|
||||
if cls._store[name] <= 0:
|
||||
raise ErrorLimiterTrigger(name)
|
||||
else:
|
||||
raise ErrorLimiterWarning(f"ErrorLimiter for '{name}' was called before setup")
|
||||
raise ErrorLimiterError(f"ErrorLimiter for '{name}' was called before setup")
|
||||
|
||||
Reference in New Issue
Block a user