1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00
This commit is contained in:
Rob Ede
2023-03-13 17:59:23 +00:00
parent 1a3fedc78f
commit 5fa564fd4e
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
// <helpers>
use actix_web::{error, get, App, HttpServer, Result};
use actix_web::{error, get, App, HttpServer};
#[derive(Debug)]
struct MyError {
@ -7,10 +7,10 @@ struct MyError {
}
#[get("/")]
async fn index() -> Result<&'static str> {
let result: Result<&'static str, MyError> = Err(MyError { name: "test error" });
async fn index() -> actix_web::Result<String> {
let result = Err(MyError { name: "test error" });
Ok(result.map_err(|e| error::ErrorBadRequest(e.name))?)
result.map_err(|err| error::ErrorBadRequest(err.name))
}
// </helpers>