1use std::sync::Arc;
2
3use tonic::codegen::StdError;
4
5use crate::generated::ReadRequestTupleKey;
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error, Clone)]
10pub enum Error {
11 #[error("Multiple stores with the name `{0}` found")]
12 AmbiguousStoreName(String),
13 #[error("Request to OpenFGA failed with status: {0}")]
14 RequestFailed(tonic::Status),
15 #[error("Too many pages returned for read request {tuple}. Max pages: {max_pages}")]
16 TooManyPages {
17 max_pages: u32,
18 tuple: ReadRequestTupleKey,
19 },
20 #[error("Invalid Endpoint: `{0}`")]
21 InvalidEndpoint(String),
22 #[error("Invalid Token: {reason}")]
23 InvalidToken { reason: String },
24 #[cfg(feature = "auth-middle")]
25 #[error("Failed to fetch or refresh Client Credentials: {0}")]
26 CredentialRefreshError(#[source] middle::Error),
27 #[error(
28 "Invalid OpenFGA Model Version: `{0}`. Model Versions must have the format `major.minor`"
29 )]
30 InvalidModelVersion(String),
31 #[error("Migration Hook for model version {version} failed: {error}")]
32 MigrationHookFailed {
33 version: String,
34 error: Arc<StdError>,
35 },
36 #[error("Store with Name `{0}` not found")]
37 StoreNotFound(String),
38 #[error("Multiple authorization models with model prefix `{model_prefix}` for version `{version}` found.")]
39 AmbiguousModelVersion {
40 model_prefix: String,
41 version: String,
42 },
43 #[error(
44 "Too many writes and deletes in single OpenFGA transaction (actual) {actual} > {max} (max)"
45 )]
46 TooManyWrites { actual: i32, max: i32 },
47 #[error("Expected Oneof variant but got None")]
53 ExpectedOneof,
54}
55
56impl Error {
57 }