1
0
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:
Cameron Dershem
2019-06-28 13:31:30 -04:00
parent cbf046b1f0
commit 5133ab874d
40 changed files with 116 additions and 81 deletions

View File

@ -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))?)

View File

@ -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>

View File

@ -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)
}