Project

General

Profile

Actions

Bug #123

open

refactor exceptions to avoid superfluous message attribute

Added by Sam Pearson 4 months ago. Updated 23 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/26/2026
Due date:
% Done:

0%

Estimated time:
Engineering Effort:
medium
App Component:
Database
Feature:

Description

We have a bunch of exceptions that make use of a superfluous "message" attribute:

class TaskValidationError(ValidationError):
    def __init__(self, message: str):
        self.message = message
        super().__init__(message)

This is unnecessary. Exceptions store their message in arg[0] and you can just do str(e) to fetch them.
You can just do this:

            raise ValidationError(f"Remote calendar {remote_uid} not found.")

And then later:

        return jsonify({"error": str(e)}), 401

We should replace all instances of e.message with str(e), and then remove the class definition for exceptions entirely (unless some of them have something other than saving a "message" attribute.


Related issues 1 (1 open0 closed)

Related to Task #131: unify 404 handlingNew04/06/2026

Actions
Actions #1

Updated by Sam Pearson 4 months ago

  • Subject changed from refactor exceptions to refactor exceptions to avoid superfluous message attribute
Actions #2

Updated by Sam Pearson 3 months ago

  • Related to Task #131: unify 404 handling added
Actions #3

Updated by Sam Pearson 3 months ago

  • Related to deleted (Task #131: unify 404 handling)
Actions #4

Updated by Sam Pearson 3 months ago

  • Related to Task #131: unify 404 handling added
Actions #5

Updated by Sam Pearson 23 days ago

  • Engineering Effort set to medium
  • App Component set to Database

Changing the exceptions themselves should be pretty simple but then all the places where they're used also need to be refactored. But the refactoring should be simple, it's a simple object, so probably medium eng effort?

Actions

Also available in: Atom PDF