mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	fix: add fallback to reverselookup error (#3025)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -1,4 +1,4 @@ | ||||
| #[derive(Debug, thiserror::Error)] | ||||
| #[derive(Copy, Clone, Debug, thiserror::Error)] | ||||
| pub enum DatabaseError { | ||||
|     #[error("An error occurred when obtaining database connection")] | ||||
|     DatabaseConnectionError, | ||||
| @ -14,3 +14,17 @@ pub enum DatabaseError { | ||||
|     #[error("An unknown error occurred")] | ||||
|     Others, | ||||
| } | ||||
|  | ||||
| impl From<diesel::result::Error> for DatabaseError { | ||||
|     fn from(error: diesel::result::Error) -> Self { | ||||
|         match error { | ||||
|             diesel::result::Error::DatabaseError( | ||||
|                 diesel::result::DatabaseErrorKind::UniqueViolation, | ||||
|                 _, | ||||
|             ) => Self::UniqueViolation, | ||||
|             diesel::result::Error::NotFound => Self::NotFound, | ||||
|             diesel::result::Error::QueryBuilderError(_) => Self::QueryGenerationFailed, | ||||
|             _ => Self::Others, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Kartikeya Hegde
					Kartikeya Hegde