Skip to content

Commit

Permalink
Replace logger.exit(...) from the internals
Browse files Browse the repository at this point in the history
Replace with raise ValueError instead so that the caller has the option to
handle the problem as they desire.

Fixes: #154
Signed-off-by: Andrew Woodward <[email protected]>
  • Loading branch information
xarses committed Sep 14, 2024
1 parent 5d7b80d commit c761fcf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions oras/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import requests

from oras.logger import logger

from .basic import BasicAuth
from .token import TokenAuth

Expand All @@ -11,7 +9,7 @@
def get_auth_backend(name="token", session=None, **kwargs):
backend = auth_backends.get(name)
if not backend:
logger.exit(f"Authentication backend {backend} is not known.")
raise ValueError(f"Authentication backend {backend} is not known.")
backend = backend(**kwargs)
backend.session = session or requests.Session()
return backend
2 changes: 1 addition & 1 deletion oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def do_request(
# Otherwise, authenticate the request and retry
headers, changed = self.auth.authenticate_request(response, headers)
if not changed:
logger.exit("Cannot respond to request for authentication.")
raise ValueError("Cannot respond to request for authentication.")
response = self.session.request(
method,
url,
Expand Down

0 comments on commit c761fcf

Please sign in to comment.