File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111from enum import Enum
1212
1313
14+ class AuthenticationError (RuntimeError ):
15+ """Raised when collector credentials are rejected (HTTP 401/403 or equivalent)."""
16+
17+
1418class CollectorFailureCategory (str , Enum ):
1519 """High-level failure bucket for collector runs."""
1620
@@ -183,6 +187,8 @@ def classify_failure(exc: BaseException) -> CollectorFailureCategory:
183187 return CollectorFailureCategory .COMMAND
184188 if ValidationError and isinstance (exc , ValidationError ):
185189 return CollectorFailureCategory .VALIDATION
190+ if isinstance (exc , AuthenticationError ):
191+ return CollectorFailureCategory .AUTH
186192
187193 try :
188194 from django .db import Error as DjangoDBError
Original file line number Diff line number Diff line change 1010from django .core .management .base import CommandError
1111
1212from core .errors import (
13+ AuthenticationError ,
1314 CollectorFailureCategory ,
1415 _classify_os_error ,
1516 classify_failure ,
@@ -58,6 +59,13 @@ def test_classify_command_error():
5859 assert classify_failure (CommandError ("bad" )) is CollectorFailureCategory .COMMAND
5960
6061
62+ def test_classify_authentication_error ():
63+ assert (
64+ classify_failure (AuthenticationError ("bad creds" ))
65+ is CollectorFailureCategory .AUTH
66+ )
67+
68+
6169def test_classify_django_db_error_unknown ():
6270 from django .db import OperationalError
6371
You can’t perform that action at this time.
0 commit comments