Commit 0bb8e43a authored by Matthias's avatar Matthias
Browse files

use more specific exceptions

parent cdfe0ced
from flask_restful import Resource, current_app
from kafka import KafkaConsumer, TopicPartition
from kafka.errors import KafkaError
import json
......@@ -52,7 +53,7 @@ class JobReport(Resource):
auto_offset_reset='earliest',
enable_auto_commit=False
)
except Exception:
except KafkaError:
current_app.logger.error('It was not possible to connect to the Kafka broker')
return {'error': 'Unexpected Kafka error'}, 500
......@@ -71,7 +72,7 @@ class JobReport(Resource):
report = report[:-2]
else:
report = 'no messages found'
except Exception:
except KafkaError:
current_app.logger.error('It was not possible to consume the Kafka messages')
return {'error': 'Unexpected Kafka error'}, 500
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment