Skip to content

Commit

Permalink
(WIP) handle gnoc api errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Apr 29, 2024
1 parent df8966f commit f5c6024
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gnocpush/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import sys

from flask import Flask, request
from flask import Flask, request, jsonify
from gnocpush import Pusher
from prometheus_flask_exporter import PrometheusMetrics

Expand All @@ -23,7 +23,13 @@ def push_endpoint():

log.debug(f"Received data: {json.dumps(data)}")

yeeter.push(data['alerts'])
try:
yeeter.push(data['alerts'])
# XXX testing
raise Exception("This is a test exception")
except Exception as e:
log.error(f"Failed to push alerts to GNOC: {str(e)}")
return jsonify(error=str(e)), 502

# Return a response
return {'status': 'success'}
Expand Down

0 comments on commit f5c6024

Please sign in to comment.