Skip to content

Commit

Permalink
proper error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Midnight95 committed Oct 3, 2023
1 parent ae7fec7 commit e51c4b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 6 additions & 1 deletion page_analyzer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ def check_url(id):
render_url(id=id, table='urls', col='id')[0]['name'],
timeout=5
)
except requests.exceptions.RequestException:
except (
requests.Timeout,
requests.ConnectionError,
requests.HTTPError,
requests.RequestException
):
flash('Произошла ошибка при проверке', 'error')
return redirect(url_for('url_info', id=id))

Expand Down
1 change: 0 additions & 1 deletion page_analyzer/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ def get_last_status_codes(checks):
}

return result

12 changes: 8 additions & 4 deletions page_analyzer/templates/urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ <h1>Сайты</h1>
</a>
</td>
<td>
{% if site.created_at %}
{{ site.created_at }}
{% if checks %}
{% if checks[site.id] %}
{{ checks[site.id].created_at }}
{% endif %}
{% endif %}
</td>
<td>
{% if site.response %}
{{ site.response }}
{% if checks %}
{% if checks[site.id] %}
{{ checks[site.id].status_code }}
{% endif %}
{% endif %}
</td>
</tr>
Expand Down

0 comments on commit e51c4b5

Please sign in to comment.