summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-20 12:24:03 -0700
committerAndrew Godwin2022-11-20 12:24:03 -0700
commit77643a4fe144cb908a372a2ceb99f36634457ca5 (patch)
tree92e37e8a9e242a31d915eb60a0ab0c14bda2bcec
parentfacdd2c08094ad378351375541fa8e65459fa8d1 (diff)
downloadtakahe-77643a4fe144cb908a372a2ceb99f36634457ca5.tar.gz
takahe-77643a4fe144cb908a372a2ceb99f36634457ca5.tar.bz2
takahe-77643a4fe144cb908a372a2ceb99f36634457ca5.zip
Add more error handling
-rw-r--r--static/img/icon-admin.svg8
-rw-r--r--stator/models.py5
-rw-r--r--stator/runner.py7
-rw-r--r--takahe/settings/base.py2
-rw-r--r--takahe/settings/production.py1
-rw-r--r--users/models/identity.py4
-rw-r--r--users/models/inbox_message.py3
7 files changed, 23 insertions, 7 deletions
diff --git a/static/img/icon-admin.svg b/static/img/icon-admin.svg
index d495b6f..6e343c0 100644
--- a/static/img/icon-admin.svg
+++ b/static/img/icon-admin.svg
@@ -11,8 +11,8 @@
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
sodipodi:docname="icon-admin.svg"
inkscape:export-filename="icon-admin-512.png"
- inkscape:export-xdpi="12.000001"
- inkscape:export-ydpi="12.000001"
+ inkscape:export-xdpi="48.000004"
+ inkscape:export-ydpi="48.000004"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
@@ -29,8 +29,8 @@
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.5946522"
- inkscape:cx="761.78983"
- inkscape:cy="461.61437"
+ inkscape:cx="765.99397"
+ inkscape:cy="467.50016"
inkscape:current-layer="layer1"><inkscape:grid
type="xygrid"
id="grid111" /></sodipodi:namedview><defs
diff --git a/stator/models.py b/stator/models.py
index df385dd..a84f8c2 100644
--- a/stator/models.py
+++ b/stator/models.py
@@ -4,6 +4,7 @@ import traceback
from typing import ClassVar, List, Optional, Type, Union, cast
from asgiref.sync import sync_to_async
+from django.conf import settings
from django.db import models, transaction
from django.utils import timezone
from django.utils.functional import classproperty
@@ -154,6 +155,10 @@ class StatorModel(models.Model):
next_state = await current_state.handler(self)
except BaseException as e:
await StatorError.acreate_from_instance(self, e)
+ if settings.SENTRY_ENABLED:
+ from sentry_sdk import capture_exception
+
+ capture_exception(e)
traceback.print_exc()
else:
if next_state:
diff --git a/stator/runner.py b/stator/runner.py
index d286bc1..ed459be 100644
--- a/stator/runner.py
+++ b/stator/runner.py
@@ -5,6 +5,7 @@ import traceback
import uuid
from typing import List, Optional, Type
+from django.conf import settings
from django.utils import timezone
from stator.models import StatorModel
@@ -90,7 +91,11 @@ class StatorRunner:
f"Attempting transition on {instance._meta.label_lower}#{instance.pk} from state {instance.state}"
)
await instance.atransition_attempt()
- except BaseException:
+ except BaseException as e:
+ if settings.SENTRY_ENABLED:
+ from sentry_sdk import capture_exception
+
+ capture_exception(e)
traceback.print_exc()
def remove_completed_tasks(self):
diff --git a/takahe/settings/base.py b/takahe/settings/base.py
index 719e03b..0ab3035 100644
--- a/takahe/settings/base.py
+++ b/takahe/settings/base.py
@@ -116,3 +116,5 @@ ALLOWED_HOSTS = ["*"]
AUTO_ADMIN_EMAIL: Optional[str] = None
STATOR_TOKEN: Optional[str] = None
+
+SENTRY_ENABLED = False
diff --git a/takahe/settings/production.py b/takahe/settings/production.py
index 4120217..b23093f 100644
--- a/takahe/settings/production.py
+++ b/takahe/settings/production.py
@@ -91,3 +91,4 @@ if "SENTRY_DSN" in os.environ:
traces_sample_rate=1.0,
send_default_pii=True,
)
+ SENTRY_ENABLED = True
diff --git a/users/models/identity.py b/users/models/identity.py
index 452bde7..a78a451 100644
--- a/users/models/identity.py
+++ b/users/models/identity.py
@@ -277,7 +277,7 @@ class Identity(StatorModel):
headers={"Accept": "application/json"},
follow_redirects=True,
)
- except (httpx.ReadTimeout, httpx.ReadError, httpx.RemoteProtocolError):
+ except httpx.RequestError:
return None, None
if response.status_code >= 400:
return None, None
@@ -306,7 +306,7 @@ class Identity(StatorModel):
headers={"Accept": "application/json"},
follow_redirects=True,
)
- except (httpx.ReadTimeout, httpx.ReadError, httpx.RemoteProtocolError):
+ except httpx.RequestError:
return False
if response.status_code >= 400:
return False
diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py
index ee23ae6..fc81d71 100644
--- a/users/models/inbox_message.py
+++ b/users/models/inbox_message.py
@@ -65,6 +65,9 @@ class InboxMessageStates(StateGraph):
f"Cannot handle activity of type undo.{unknown}"
)
case "delete":
+ # If there is no object type, it's probably a profile
+ if not isinstance(instance.message["object"], dict):
+ raise ValueError("Cannot handle activity of type delete")
match instance.message_object_type:
case "tombstone":
await sync_to_async(Post.handle_delete_ap)(instance.message)