Skip to main content

rialo_feature_management_interface/
error.rs

1// Copyright (c) Subzero Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Error types for the Feature Management Program
5
6use rialo_s_instruction::error::InstructionError;
7use rialo_s_program_error::{PrintProgramError, ProgramError};
8
9/// Errors that can be returned by the Feature Management Program
10///
11/// Error codes are explicitly assigned to ensure stability across versions.
12/// Do not reorder variants or change their discriminant values.
13#[derive(Debug, Clone, PartialEq, Eq)]
14#[repr(u32)]
15pub enum FeatureManagementError {
16    /// Unauthorized access - signature verification failed
17    Unauthorized = 0,
18
19    /// Invalid feature name (empty or too long)
20    InvalidFeatureName = 1,
21
22    /// Feature not found
23    FeatureNotFound = 2,
24
25    /// Invalid time range (start time >= end time)
26    InvalidTimeRange = 3,
27
28    /// Serialization error
29    SerializationError = 4,
30
31    /// Deserialization error
32    DeserializationError = 5,
33
34    /// Invalid instruction data
35    InvalidInstructionData = 6,
36
37    /// Internal error (e.g., mutex lock failure)
38    InternalError = 7,
39
40    /// Duplicate feature in modification list
41    DuplicateFeature = 8,
42
43    /// Invalid storage account (not the expected PDA)
44    InvalidStorageAccount = 9,
45
46    /// Storage account already initialized
47    AlreadyInitialized = 10,
48
49    /// Storage account not initialized
50    NotInitialized = 11,
51}
52
53impl From<FeatureManagementError> for ProgramError {
54    fn from(e: FeatureManagementError) -> Self {
55        ProgramError::Custom(e as u32)
56    }
57}
58
59impl From<FeatureManagementError> for InstructionError {
60    fn from(e: FeatureManagementError) -> Self {
61        InstructionError::Custom(e as u32)
62    }
63}
64
65impl PrintProgramError for FeatureManagementError {
66    fn print<E>(&self) {}
67}