mirror of
https://github.com/actix/actix-website
synced 2025-06-27 07:29:02 +02:00
Final fixes before requesting review.
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
use actix_web::{web, App};
|
||||
// <helpers>
|
||||
use actix_web::{error, HttpRequest, Result};
|
||||
use actix_web::{error, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MyError {
|
||||
name: &'static str,
|
||||
}
|
||||
|
||||
pub fn index(_req: HttpRequest) -> Result<&'static str> {
|
||||
pub fn index() -> Result<&'static str> {
|
||||
let result: Result<&'static str, MyError> = Err(MyError { name: "test error" });
|
||||
|
||||
Ok(result.map_err(|e| error::ErrorBadRequest(e.name))?)
|
||||
|
@ -16,7 +16,7 @@ pub struct MyError {
|
||||
// Use default implementation for `error_response()` method
|
||||
impl error::ResponseError for MyError {}
|
||||
|
||||
fn index(_req: HttpRequest) -> Result<&'static str, MyError> {
|
||||
fn index() -> Result<&'static str, MyError> {
|
||||
Err(MyError { name: "test" })
|
||||
}
|
||||
// </response-error>
|
||||
|
@ -1,6 +1,6 @@
|
||||
use actix_web::{web, App};
|
||||
// <override>
|
||||
use actix_web::{error, http, HttpRequest, HttpResponse};
|
||||
use actix_web::{error, http, HttpResponse};
|
||||
use failure::Fail;
|
||||
|
||||
#[derive(Fail, Debug)]
|
||||
@ -25,16 +25,16 @@ impl error::ResponseError for MyError {
|
||||
}
|
||||
}
|
||||
|
||||
fn index(_req: HttpRequest) -> Result<&'static str, MyError> {
|
||||
fn index() -> Result<&'static str, MyError> {
|
||||
Err(MyError::BadClientData)
|
||||
}
|
||||
// </override>
|
||||
|
||||
fn error2(_req: HttpRequest) -> Result<&'static str, MyError> {
|
||||
fn error2() -> Result<&'static str, MyError> {
|
||||
Err(MyError::InternalError)
|
||||
}
|
||||
|
||||
fn error3(_req: HttpRequest) -> Result<&'static str, MyError> {
|
||||
fn error3() -> Result<&'static str, MyError> {
|
||||
Err(MyError::Timeout)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user