Skip to content

Commit 7d8f8a9

Browse files
Adam BaloghAdam Balogh
authored andcommitted
handle err
1 parent eefe62d commit 7d8f8a9

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

agent/telemetry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def wrapper(*args, **kwargs):
3232
tags = [
3333
f"tool_name:{tool_name}",
3434
f"error_type:{type(e).__name__}",
35-
f"environment:{os.environ.get('ENVIRONMENT', 'development')}",
3635
]
3736
statsd.increment("tool.errors.count", tags=tags)
3837
statsd.histogram("tool.execution.duration", duration, tags=tags)
38+
3939
logging.error(
40-
f"Error in tool {tool_name} with input {args} and kwargs {kwargs}: {e}"
40+
f"Error in tool: {tool_name} with input {args} and kwargs {kwargs}: {e}"
4141
)
42+
return f"ERROR: Failed to execute tool {tool_name}."
4243

43-
raise e
4444

4545
return wrapper
4646

onchain/tokens/trending.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ def get_top_token_holders(
4141
chain, address = token_id.split(":", 1)
4242
chain = chain.lower()
4343

44-
try:
45-
holders, error = get_top_token_holders_from_coingecko(address, chain)
46-
if error:
47-
return error
44+
holders, error = get_top_token_holders_from_coingecko(address, chain)
45+
if error:
46+
return error
4847

49-
return f"""Top holders of {address} on {chain}: {holders}."""
50-
except Exception as e:
51-
logging.error(f"Error in get_top_token_holders with input {token_id}: {e}")
52-
return f"ERROR: Failed to get top holders for {token_id}: {e}"
48+
return f"""Top holders of {address} on {chain}: {holders}."""
5349

5450

5551
@cached(cache=TTLCache(maxsize=10_000, ttl=60 * 10))
@@ -104,13 +100,8 @@ def get_trending_tokens(
104100
) -> str:
105101
"""Retrieve the latest trending tokens on the given chain from DEX data."""
106102
chain = chain.lower()
107-
108-
try:
109-
trending_tokens = get_trending_tokens_from_coingecko(chain)[:8]
110-
return f"""Latest trending tokens: {trending_tokens}. In your answer, include the ID of each token you mention in the following format: ```token:<insert token_id>```, and also the name and symbol of each token."""
111-
except Exception as e:
112-
logging.error(f"Error in get_trending_tokens with input {chain}: {e}")
113-
return f"ERROR: Failed to get trending tokens for {chain}: {e}"
103+
trending_tokens = get_trending_tokens_from_coingecko(chain)[:8]
104+
return f"""Latest trending tokens: {trending_tokens}. In your answer, include the ID of each token you mention in the following format: ```token:<insert token_id>```, and also the name and symbol of each token."""
114105

115106

116107
@tool

0 commit comments

Comments
 (0)