October 2019
Intermediate to advanced
444 pages
10h 37m
English
You are just a few steps away from understanding error handling with actix-web:
#[macro_use]extern crate actix_web;use failure::Fail;use actix_web::{ http, middleware, web, App, HttpResponse, HttpServer, error};use serde_derive::{Deserialize, Serialize};use std::env;
#[derive(Fail, Debug)]enum WebError { #[fail(display = "Invalid id '{}'", id)] InvalidIdError { id: i32 }, #[fail(display = "Invalid request, please try again later")] RandomInternalError,}impl error::ResponseError for WebError { fn error_response(&self) -> HttpResponse { match ...Read now
Unlock full access