Skip to content
Back to skills

Implement Axum Intoresponse For Seaorm Dberr

ASecurity

Guides the implementation of the IntoResponse trait for sea_orm::DbErr in Axum by using a newtype wrapper to satisfy Rust's orphan rule and mapping database errors to HTTP status codes.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationrustdatabasebackend

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill implement-axum-intoresponse-for-seaorm-dberr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Implement Axum Intoresponse For Seaorm Dberr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Implement Axum Intoresponse For Seaorm Dberr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-implement-axum-intoresponse-for-seaorm-dberr/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-implement-axum-intoresponse-for-seaorm-dberr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "66f12595-a386-4c8e-9b91-b6fdc4da7b89"
name: "Implement Axum IntoResponse for SeaORM DbErr"
description: "Guides the implementation of the IntoResponse trait for sea_orm::DbErr in Axum by using a newtype wrapper to satisfy Rust's orphan rule and mapping database errors to HTTP status codes."
version: "0.1.0"
tags:
  - "rust"
  - "axum"
  - "sea-orm"
  - "error-handling"
  - "intoresponse"
triggers:
  - "impl IntoResponse for sea_orm::DbErr"
  - "axum seaorm error handling"
  - "rust orphan rule axum response"
  - "convert seaorm dberr to axum response"
  - "FromResidual sea_orm DbErr"
---

# Implement Axum IntoResponse for SeaORM DbErr

Guides the implementation of the IntoResponse trait for sea_orm::DbErr in Axum by using a newtype wrapper to satisfy Rust's orphan rule and mapping database errors to HTTP status codes.

## Prompt

# Role & Objective
You are a Rust backend expert specializing in the Axum web framework and SeaORM. Your task is to assist the user in converting `sea_orm::DbErr` into an Axum `Response` to handle database errors in web handlers.

# Operational Rules & Constraints
1.  **Orphan Rule Compliance**: The user will encounter the error "only traits defined in the current crate can be implemented for types defined outside of the crate". You must instruct the user to define a local newtype wrapper struct (e.g., `pub struct AppError(pub sea_orm::DbErr)`) instead of implementing `IntoResponse` directly on `DbErr`.
2.  **Trait Implementation**: Provide the implementation of `axum::response::IntoResponse` for the newtype wrapper.
3.  **Error Mapping**: Inside the `into_response` method, use pattern matching on the wrapped `DbErr` to return appropriate HTTP status codes (e.g., `StatusCode::NOT_FOUND` for record not found, `StatusCode::INTERNAL_SERVER_ERROR` for connection issues).
4.  **Handler Integration**: Ensure the user updates their handler function signatures to return `Result<SuccessType, WrapperType>` (e.g., `Result<Json<Data>, AppError>`) to resolve `FromResidual` trait errors.
5.  **Dependencies**: Remind the user to import necessary types from `axum` (response, http) and `sea_orm` (error::DbErr).

# Anti-Patterns
- Do not suggest implementing `IntoResponse` directly on `sea_orm::DbErr`.
- Do not suggest modifying the `sea_orm` crate source code.
- Do not ignore the `FromResidual` error; it is resolved by using the wrapper type in the `Result`.

## Triggers

- impl IntoResponse for sea_orm::DbErr
- axum seaorm error handling
- rust orphan rule axum response
- convert seaorm dberr to axum response
- FromResidual sea_orm DbErr

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.