Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the .message field on exceptions non-empty #2947

Merged
merged 8 commits into from
Jun 22, 2024

Commits on May 6, 2024

  1. Make the .message field on exceptions non-empty

    This allows subclasses of SanicException to access their message via the `message` attribute. This makes it consistent with the `status_code`, `quiet`, `headers` attributes that were previously present on the class.
    
    Currently, the message attribute is present on the class but not on the instance, so accessing SanicException().message will return an empty string "" instead of the actual message "Internal Server Error", which you can get by calling the __str__() method or str().
    
    This is a bit surprising, since the .message attribute shows up in autocomplete and type-checking. It also happens for the other exceptions, like str(BadRequest()) == "" as well.
    
    I set the message attribute on instances of SanicException and added tests for this new behavior.
    ekzhang committed May 6, 2024
    Configuration menu
    Copy the full SHA
    464fedb View commit details
    Browse the repository at this point in the history
  2. Type error?

    ekzhang authored May 6, 2024
    Configuration menu
    Copy the full SHA
    a2c7c8d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ad45554 View commit details
    Browse the repository at this point in the history
  4. Update exceptions.py

    ekzhang authored May 6, 2024
    Configuration menu
    Copy the full SHA
    7901b2c View commit details
    Browse the repository at this point in the history
  5. Try to fix type inference?

    ekzhang authored May 6, 2024
    Configuration menu
    Copy the full SHA
    d7ed99c View commit details
    Browse the repository at this point in the history

Commits on Jun 22, 2024

  1. Configuration menu
    Copy the full SHA
    aa27518 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b16c26a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9084a74 View commit details
    Browse the repository at this point in the history