cranpose-services 0.24.0

Multiplatform service contracts and platform integrations for Cranpose apps
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{ContentError, HttpError};

pub(super) fn content_error(error: HttpError) -> ContentError {
    match error {
        HttpError::RequestFailed { .. } | HttpError::BodyReadFailed { .. } => {
            ContentError::Unreachable(error.to_string())
        }
        HttpError::HttpStatus {
            url,
            status: 401 | 403,
        } => ContentError::PermissionDenied(url),
        HttpError::HttpStatus { url, status: 404 } => ContentError::NotFound(url),
        error => ContentError::Io(error.to_string()),
    }
}