Skip to content

Commit

Permalink
cursor support
Browse files Browse the repository at this point in the history
  • Loading branch information
acer-king committed Nov 28, 2024
1 parent f4e6a20 commit ba02da7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions validators/core/axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,36 @@ def default_verify(self, synapse: bittensor.Synapse):
raise SynapseDendriteNoneException()



def log_and_handle_error(
synapse: bittensor.Synapse,
exception: Exception,
status_code: int,
start_time: float,
):
# Display the traceback for user clarity.
bittensor.logging.trace(f"Forward exception: {traceback.format_exc()}")

# Set the status code of the synapse to the given status code.
error_type = exception.__class__.__name__
error_message = str(exception)
detailed_error_message = f"{error_type}: {error_message}"

# Log the detailed error message for internal use
bittensor.logging.error(detailed_error_message)

if synapse.axon is None:
raise SynapseParsingError(detailed_error_message)
# Set a user-friendly error message
synapse.axon.status_code = status_code
synapse.axon.status_message = error_message

# Calculate the processing time by subtracting the start time from the current time.
synapse.axon.process_time = str(time.time() - start_time) # type: ignore

return synapse


class CortexAxonMiddleware(BaseHTTPMiddleware):
"""
The `AxonMiddleware` class is a key component in the Axon server, responsible for processing all incoming requests.
Expand Down

0 comments on commit ba02da7

Please sign in to comment.