The smokesignal.events web application
at main 79 lines 3.1 kB view raw
1use thiserror::Error; 2 3/// Represents errors that can occur during LFG (Looking For Group) operations. 4/// 5/// These errors are typically triggered during validation of user-submitted 6/// LFG creation forms or during LFG record operations. 7#[derive(Debug, Error)] 8pub(crate) enum LfgError { 9 /// Error when the location is not provided. 10 /// 11 /// This error occurs when a user attempts to create an LFG record without 12 /// selecting a location on the map. 13 #[error("error-smokesignal-lfg-1 Location not set")] 14 LocationNotSet, 15 16 /// Error when the coordinates are invalid. 17 /// 18 /// This error occurs when the provided latitude or longitude 19 /// values are not valid numbers or are out of range. 20 #[error("error-smokesignal-lfg-2 Invalid coordinates: {0}")] 21 InvalidCoordinates(String), 22 23 /// Error when no tags are provided. 24 /// 25 /// This error occurs when a user attempts to create an LFG record without 26 /// specifying at least one interest tag. 27 #[error("error-smokesignal-lfg-3 Tags required (at least one)")] 28 TagsRequired, 29 30 /// Error when too many tags are provided. 31 /// 32 /// This error occurs when a user attempts to create an LFG record with 33 /// more than the maximum allowed number of tags (10). 34 #[error("error-smokesignal-lfg-4 Too many tags (maximum 10)")] 35 TooManyTags, 36 37 /// Error when an invalid duration is specified. 38 /// 39 /// This error occurs when the provided duration value is not one of 40 /// the allowed options (6, 12, 24, 48, or 72 hours). 41 #[error("error-smokesignal-lfg-5 Invalid duration")] 42 InvalidDuration, 43 44 /// Error when the PDS record creation fails. 45 /// 46 /// This error occurs when the AT Protocol server returns an error 47 /// during LFG record creation. 48 #[error("error-smokesignal-lfg-6 Failed to create PDS record: {message}")] 49 PdsRecordCreationFailed { message: String }, 50 51 /// Error when no active LFG record is found. 52 /// 53 /// This error occurs when attempting to perform operations that 54 /// require an active LFG record (e.g., deactivation, viewing matches). 55 #[error("error-smokesignal-lfg-7 No active LFG record found")] 56 NoActiveRecord, 57 58 /// Error when user already has an active LFG record. 59 /// 60 /// This error occurs when a user attempts to create a new LFG record 61 /// while they already have an active one. Users must deactivate their 62 /// existing record before creating a new one. 63 #[error("error-smokesignal-lfg-8 Active LFG record already exists")] 64 ActiveRecordExists, 65 66 /// Error when deactivation fails. 67 /// 68 /// This error occurs when the attempt to deactivate an LFG record 69 /// fails due to a server or network error. 70 #[error("error-smokesignal-lfg-9 Failed to deactivate LFG record: {message}")] 71 DeactivationFailed { message: String }, 72 73 /// Error when a tag is invalid. 74 /// 75 /// This error occurs when a provided tag is empty or exceeds 76 /// the maximum allowed length. 77 #[error("error-smokesignal-lfg-10 Invalid tag: {0}")] 78 InvalidTag(String), 79}