mirror of
https://git.wownero.com/lza_menace/wowstash.git
synced 2024-08-15 00:33:15 +00:00
catch 500 errors and notify discord
This commit is contained in:
parent
f178878fb5
commit
1a48e7db77
3 changed files with 47 additions and 0 deletions
|
@ -4,8 +4,14 @@ from wowstash.library.jsonrpc import daemon
|
|||
from wowstash.library.cache import cache
|
||||
from wowstash.library.db import Database
|
||||
from wowstash.library.docker import Docker
|
||||
from wowstash.library.helpers import post_discord_webhook
|
||||
|
||||
|
||||
@meta_bp.errorhandler(500)
|
||||
def internal_error(error):
|
||||
post_discord_webhook(f'500 error: {error.original_exception}')
|
||||
return render_template('meta/500.html', error=error)
|
||||
|
||||
@meta_bp.route('/')
|
||||
def index():
|
||||
return render_template('meta/index.html', node=daemon.info(), info=cache.get_coin_info())
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import requests
|
||||
|
||||
from wowstash.models import Event
|
||||
from wowstash.factory import db
|
||||
from wowstash import config
|
||||
|
||||
|
||||
def capture_event(user_id, event_type):
|
||||
|
@ -10,3 +13,11 @@ def capture_event(user_id, event_type):
|
|||
db.session.add(event)
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
def post_discord_webhook(text):
|
||||
try:
|
||||
r = requests.post(config.DISCORD_URL, data={"content": text})
|
||||
r.raise_for_status()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
|
30
wowstash/templates/meta/500.html
Normal file
30
wowstash/templates/meta/500.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
{% include 'head.html' %}
|
||||
|
||||
<body id="page-top">
|
||||
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
<header class="masthead">
|
||||
<div class="container h-100">
|
||||
<div class="row h-100">
|
||||
<div class="col-lg-12 my-auto">
|
||||
<div class="header-content-sm mx-auto">
|
||||
<h2 class="mb-4">Error</h2>
|
||||
<p>There was an error - an administrator has been notified.</p>
|
||||
<p>Error: <code style="background-color: white;">{{ error.original_exception }}</code></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
||||
{% include 'scripts.html' %}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue