feat(ai): add custom prompt templates
This commit is contained in:
1 parent
01fde8879f
commit
1fb3e2816b
58 files changed
+2381
-502
No files matched your search
@@ -1,32 +1,39 @@
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
|
||||
pub struct AppError(pub String);
|
||||
pub struct AppError {
|
||||
pub message: String,
|
||||
pub status: StatusCode,
|
||||
}
|
||||
|
||||
impl AppError {
|
||||
pub fn internal(msg: impl Into<String>) -> Self {
|
||||
AppError(msg.into())
|
||||
AppError { message: msg.into(), status: StatusCode::INTERNAL_SERVER_ERROR }
|
||||
}
|
||||
|
||||
pub fn bad_request(msg: impl Into<String>) -> Self {
|
||||
AppError(msg.into())
|
||||
AppError { message: msg.into(), status: StatusCode::BAD_REQUEST }
|
||||
}
|
||||
|
||||
pub fn not_found(msg: impl Into<String>) -> Self {
|
||||
AppError { message: msg.into(), status: StatusCode::NOT_FOUND }
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for AppError {
|
||||
fn into_response(self) -> Response {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, self.0).into_response()
|
||||
(self.status, self.message).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for AppError {
|
||||
fn from(s: String) -> Self {
|
||||
AppError(s)
|
||||
AppError { message: s, status: StatusCode::INTERNAL_SERVER_ERROR }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for AppError {
|
||||
fn from(s: &str) -> Self {
|
||||
AppError(s.to_string())
|
||||
AppError { message: s.to_string(), status: StatusCode::INTERNAL_SERVER_ERROR }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user