RRule error handling #422

This commit is contained in:
Daniel Grams 2023-04-11 22:52:24 +02:00
parent f93bb4c65f
commit 8fdcbe9457
3 changed files with 24 additions and 5 deletions

View File

@ -1354,7 +1354,7 @@
element.find('.rioccurrences').show();
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
alert(textStatus + " " + jqXHR.statusText + " " + jqXHR.responseText);
}
};

View File

@ -275,10 +275,14 @@ def event_rrule():
from project.dateutils import calculate_occurrences
result = calculate_occurrences(
start_date, '"%d.%m.%Y"', rrule_str, start, batch_size
)
return jsonify(result)
try:
result = calculate_occurrences(
start_date, '"%d.%m.%Y"', rrule_str, start, batch_size
)
return jsonify(result)
except Exception as e:
app.logger.exception(request.json)
return str(e), 400
def get_event_category_choices():

View File

@ -643,6 +643,21 @@ def test_rrule(client, seeder, utils, app):
assert occurence["formattedDate"] == '"25.11.2020"'
def test_rrule_bad_request(client, seeder, utils, app):
url = utils.get_url("event_rrule")
response = utils.post_json(
url,
{
"year": 2020,
"month": 11,
"day": 25,
"rrule": "RRULE:FREQ=DAILY;COUNT=7bad",
"start": 0,
},
)
utils.assert_response_bad_request(response)
def test_report(seeder, utils):
user_id, admin_unit_id = seeder.setup_base()
event_id = seeder.create_event(admin_unit_id)