waddling-errors-macros 0.7.3

Procedural macros for structured error codes with compile-time validation and taxonomy enforcement
Documentation
//! Storage Component
//!
//! S3-compatible object storage - file uploads, downloads, versioning, presigned URLs.
//!
//! This version uses the `component!` and `diag!` macros from waddling-errors-macros.

use waddling_errors_macros::{component, component_location, diag};

// Mark this file as Storage component - developer level
component_location!(Storage, role = developer);

component! {
    Storage {
        docs: "S3-compatible object storage. Handles file uploads, downloads, versioning, and presigned URL generation.",
        examples: [
            "E.Storage.Permission.DENIED: S3 bucket access denied",
            "C.Storage.Data.CORRUPTED: Object integrity check failed (corrupt upload)",
            "K.Storage.Data.UPLOADED: Multipart upload completed successfully"
        ],
        tags: ["files", "s3", "objects"],
    },
}

// ============================================================================
// Error Code Definitions
// ============================================================================

diag! {
    <json, html>,


    E.Storage.Permission.DENIED: {
        message: "S3 bucket access denied",
        'CR 'Pub description: "Access to the S3 bucket was denied. Insufficient permissions for the requested operation.",
        'CR 'Pub hints: [
            "Check IAM permissions",
            "Verify bucket policy"
        ],
        'CR 'Int hints: [
            "Review IAM role assignments",
            "Check bucket ACLs",
            "Verify cross-account access settings"
        ],
        'R role: "Internal",
        'R tags: ["storage", "permissions", "s3"],
    },

    C.Storage.Data.CORRUPTED: {
        message: "CRITICAL: Object corruption detected",
        'CR 'Pub description: "Object corruption was detected during integrity check. The stored data does not match the expected checksum.",
        'CR 'Pub hints: [
            "Verify upload integrity",
            "Retry upload",
            "Check storage health"
        ],
        'CR 'Int hints: [
            "Compare MD5/SHA256 checksums",
            "Check S3 versioning status",
            "Review upload logs for errors"
        ],
        'R role: "Internal",
        'R tags: ["storage", "integrity", "critical"],
        'R related_codes: ["C.Db.Data.CORRUPTED"],
    },

    E.Storage.Data.ALREADY_EXISTS: {
        message: "Object already exists - upload conflict",
        'CR 'Pub description: "The object already exists in storage. Cannot overwrite without explicit permission.",
        'CR 'Pub hints: [
            "Use versioning",
            "Check for existing object"
        ],
        'CR 'Dev hints: [
            "Enable S3 versioning on bucket",
            "Use conditional PUT with If-None-Match"
        ],
        'R role: "Developer",
        'R tags: ["storage", "conflict"],
    },

    E.Storage.Data.NOT_FOUND: {
        message: "Object not found in storage",
        'CR 'Pub description: "The requested object does not exist in the storage bucket.",
        'CR 'Pub hints: [
            "Verify object key",
            "Check if object was deleted"
        ],
        'CR 'Dev hints: [
            "List bucket contents to verify",
            "Check object versioning history"
        ],
        'R role: "Developer",
        'R tags: ["storage", "notfound"],
    },

    K.Storage.Data.UPLOADED: {
        message: "Multipart upload completed successfully",
        'CR 'Pub description: "The multipart upload operation completed successfully. All parts have been uploaded and assembled.",
        'CR 'Pub hints: [
            "Object is now available"
        ],
        'CR 'Dev hints: [
            "Verify object ETag",
            "Clean up any temporary upload state"
        ],
        'R role: "Developer",
        'R tags: ["storage", "upload", "success"],
    },

    T.Storage.Data.TRACE: {
        message: "Storage operation trace - debugging enabled",
        'CR 'Pub description: "Trace-level logging for storage operations. Used for debugging and performance analysis.",
        'CR 'Int hints: [
            "Review operation timing",
            "Check API call patterns"
        ],
        'R role: "Internal",
        'R tags: ["storage", "debug", "trace"],
    },
}