• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geo-engine / geoengine / 12767614094

14 Jan 2025 12:26PM UTC coverage: 90.64% (+0.06%) from 90.576%
12767614094

push

github

web-flow
Merge pull request #1006 from geo-engine/migrate-pro-api

Migrate-pro-api

1106 of 1152 new or added lines in 24 files covered. (96.01%)

248 existing lines in 13 files now uncovered.

133501 of 147287 relevant lines covered (90.64%)

54652.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/services/src/api/model/responses/datasets/errors.rs
1
use crate::api::model::responses::ErrorResponse;
2
use crate::error;
3
use actix_web::http::StatusCode;
4
use actix_web::{HttpResponse, ResponseError};
5
use geoengine_datatypes::util::helpers::ge_report;
6
use snafu::prelude::*;
7
use std::fmt;
8
use strum::IntoStaticStr;
9

UNCOV
10
#[derive(Snafu, IntoStaticStr)]
×
11
#[snafu(visibility(pub(crate)))]
12
#[snafu(context(suffix(false)))] // disables default `Snafu` suffix
13
pub enum CreateDatasetError {
14
    UploadNotFound {
15
        source: error::Error,
16
    },
17
    OnlyAdminsCanCreateDatasetFromVolume,
18
    AdminsCannotCreateDatasetFromUpload,
19
    CannotResolveUploadFilePath {
20
        source: error::Error,
21
    },
22
    #[snafu(display("Cannot create dataset: {source}"))]
23
    CannotCreateDataset {
24
        source: error::Error,
25
    },
26
    JsonValidationFailed {
27
        source: error::Error,
28
    },
29
    DatabaseAccessError {
30
        source: error::Error,
31
    },
32
    CannotAccessConfig {
33
        source: error::Error,
34
    },
35
    UnknownVolume,
36
}
37

38
impl ResponseError for CreateDatasetError {
UNCOV
39
    fn error_response(&self) -> HttpResponse {
×
UNCOV
40
        HttpResponse::build(self.status_code()).json(ErrorResponse::from(self))
×
UNCOV
41
    }
×
42

UNCOV
43
    fn status_code(&self) -> StatusCode {
×
UNCOV
44
        match self {
×
45
            Self::DatabaseAccessError { .. } | Self::CannotAccessConfig { .. } => {
46
                StatusCode::INTERNAL_SERVER_ERROR
×
47
            }
UNCOV
48
            _ => StatusCode::BAD_REQUEST,
×
49
        }
UNCOV
50
    }
×
51
}
52

53
impl fmt::Debug for CreateDatasetError {
UNCOV
54
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
UNCOV
55
        write!(f, "{}", ge_report(self))
×
UNCOV
56
    }
×
57
}
58

59
#[derive(Snafu, IntoStaticStr)]
×
60
#[snafu(visibility(pub(crate)))]
61
#[snafu(context(suffix(false)))] // disables default `Snafu` suffix
62
pub enum GetDatasetError {
63
    CannotLoadDataset { source: error::Error },
64
}
65

66
impl ResponseError for GetDatasetError {
67
    fn error_response(&self) -> HttpResponse {
×
68
        HttpResponse::build(self.status_code()).json(ErrorResponse::from(self))
×
69
    }
×
70

71
    fn status_code(&self) -> StatusCode {
×
72
        StatusCode::BAD_REQUEST
×
73
    }
×
74
}
75

76
impl fmt::Debug for GetDatasetError {
77
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
78
        write!(f, "{}", ge_report(self))
×
79
    }
×
80
}
81

82
#[derive(Snafu, IntoStaticStr)]
×
83
#[snafu(visibility(pub(crate)))]
84
#[snafu(context(suffix(false)))] // disables default `Snafu` suffix
85
pub enum UpdateDatasetError {
86
    #[snafu(display("Cannot load dataset for update"))]
87
    CannotLoadDatasetForUpdate { source: error::Error },
88
    #[snafu(display("Cannot update dataset"))]
89
    CannotUpdateDataset { source: error::Error },
90
}
91

92
impl ResponseError for UpdateDatasetError {
93
    fn error_response(&self) -> HttpResponse {
×
94
        HttpResponse::build(self.status_code()).json(ErrorResponse::from(self))
×
95
    }
×
96

97
    fn status_code(&self) -> StatusCode {
×
98
        StatusCode::BAD_REQUEST
×
99
    }
×
100
}
101

102
impl fmt::Debug for UpdateDatasetError {
103
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
104
        write!(f, "{}", ge_report(self))
×
105
    }
×
106
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc