i3f/error.rs
1use thiserror::Error;
2
3/// IiifError 定义了 IIIF 相关的错误类型
4#[derive(Debug, Error, PartialEq)]
5pub enum IiifError {
6 #[error("Invalid IIIF image URL: {0}")]
7 InvalidIiifURL(String),
8
9 /// 400 Bad Request
10 ///
11 /// 服务器无法满足请求,因为客户端发出的请求语法不正确。
12 ///
13 /// The server cannot fulfill the request, as the syntax of the request issued by the client is incorrect.
14 #[error("{0}")]
15 BadRequest(String),
16
17 /// 401 Unauthorized
18 ///
19 /// 请求要求身份验证。未提供凭据或提供凭据但无效。
20 ///
21 /// The request requires user authentication. The client must authenticate itself to get the requested response.
22 #[error("{0}")]
23 Unauthorized(String),
24
25 /// 403 Forbidden
26 ///
27 /// 用户(无论是否已认证)都不被允许执行请求的操作。
28 ///
29 /// The user, authenticated or not, is not permitted to perform the requested operation.
30 #[error("{0}")]
31 Forbidden(String),
32
33 /// 404 Not Found
34 ///
35 /// 通过标识符指定的图像资源不存在,一个或多个参数的值不受此图像服务支持,或请求的尺寸大于指定的限制。
36 ///
37 /// The image resource specified by identifier does not exist, the value of one or more of
38 /// the parameters is not supported for this image service, or the requested size is greater
39 /// than the limits specified.
40 #[error("{0}")]
41 NotFound(String),
42
43 /// 500 Internal Server Error
44 ///
45 /// 服务器遇到意外错误,导致无法满足请求。
46 ///
47 /// The server encountered an unexpected error that prevented it from fulfilling the request.
48 #[error("{0}")]
49 InternalServerError(String),
50
51 /// 501 Not Implemented
52 ///
53 /// 服务器收到了一个有效的 IIIF 请求,但该请求未实现。
54 ///
55 /// The server received a valid IIIF request that is not implemented.
56 #[error("{0}")]
57 NotImplemented(String),
58
59 /// 503 Service Unavailable
60 ///
61 /// 服务器因负载/维护问题繁忙/暂时不可用。
62 ///
63 /// The server is busy/temporarily unavailable due to load/maintenance problems.
64 #[error("{0}")]
65 ServiceUnavailable(String),
66}