Skip to content

refactor: Separate StatusCookie and OperationStatus#37

Merged
angrynode merged 1 commit intoaxumfrom
refactor-errors
Feb 23, 2026
Merged

refactor: Separate StatusCookie and OperationStatus#37
angrynode merged 1 commit intoaxumfrom
refactor-errors

Conversation

@angrynode
Copy link
Owner

Here i try to make error reporting more flexible:

  • OperationStatus can contain a stringy message or a typed error
  • OperationStatus error sources will be flattened into a list of strings for display (maybe that's not the best approach but that's already what we're doing for AppStateError)
  • StatusCookie can be extracted directly in route handlers to display the error with StatusCookie::with_template for any template that implements FallibleTemplate (to set the status in the template)
  • when producing the status to pass to another page, the CookieJar should be extracted from the route then use StatusCookie::error or StatusCookie::success, then you can produce the redirect with StatusCookie::redirect
  • added type aliases FlashRedirect and FlashTemplate<Template>

Not sure if that's the best approach in the long run (eg. for i18n) but for now that should make it easier:

<p class="mb-0">{{ flash.message }}</p>
{% for message in flash.message.messages() %}
<p class="mb-0">{{ message }}</p>
{% endfor %}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a proper display for nested errors?

@angrynode angrynode merged commit b60ed60 into axum Feb 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant