Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit bcf3719

Browse files
committed
rasing an exception prints out all stacktrace, which is not practical nor helpful. raising click.Exception only prints out the exception msg
1 parent 3664f18 commit bcf3719

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

codecov_cli/helpers/request.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import uuid
33
from time import sleep
44

5+
import click
56
import requests
67

78
from codecov_cli.types import RequestError, RequestResult
@@ -46,9 +47,11 @@ def send_post_request(
4647

4748
def get_token_header_or_fail(token: uuid.UUID) -> dict:
4849
if token is None:
49-
raise Exception("Codecov token not found.")
50+
raise click.ClickException(
51+
"Codecov token not found. Please provide Codecov token with -t flag."
52+
)
5053
if not isinstance(token, uuid.UUID):
51-
raise Exception(f"Token must be UUID. Received {type(token)}")
54+
raise click.ClickException(f"Token must be UUID. Received {type(token)}")
5255
return {"Authorization": f"token {token.hex}"}
5356

5457

tests/helpers/test_request.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def test_get_token_header_or_fail():
5757
with pytest.raises(Exception) as e:
5858
get_token_header_or_fail(token)
5959

60-
assert str(e.value) == "Codecov token not found."
60+
assert (
61+
str(e.value)
62+
== "Codecov token not found. Please provide Codecov token with -t flag."
63+
)
6164

6265
# Test with an invalid token type
6366
token = "invalid_token"

0 commit comments

Comments
 (0)