TsukiNi22/ai-utils / skills/libutils/libutils-exception
libutils-exception
Verifiedlibutils exception handling (utils::exception) - IException/AException, Error/Warning/None/Fatal/CustomException, InternalCode vs ExternalCode, Type, restrictions, formated() output, throw/catch/print patterns - and how to add new exception codes to a project (cmake/config/exceptions/*.json, generate_exception_header.py + const.py, CMake custom command, include/exception/generated_external_exception_header.hpp). Use whenever throwing, catching or printing a libutils exception, choosing an exception code, or adding/editing exception codes, the exception JSON config, the generator script or the generated_*_exception_header of a project.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.1 KB |
| requires.txt | markdown | 9 B |
| templates/cmake/config/exceptions/global.json | config | 581 B |
| templates/cmake/scripts/const.pyexecutable | script | 3.6 KB |
| templates/cmake/scripts/generate_exception_header.pyexecutable | script | 9.1 KB |
| templates/cmake/scripts/requirements.txt | manifest | 0 B |
| templates/exception.cmake | other | 1.1 KB |
templates/cmake/scripts/const.py
View on GitHub"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
██╗ ██╗ █████╗ ██████╗ ████████╗ █████╗ ███╗ ██╗██╗ █████╗
╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗████╗ ██║██║██╔══██╗
╚███╔╝ ███████║██████╔╝ ██║ ███████║██╔██╗ ██║██║███████║
██╔██╗ ██╔══██║██╔══██╗ ██║ ██╔══██║██║╚██╗██║██║██╔══██║
██╔╝ ██╗██║ ██║██║ ██║ ██║ ██║ ██║██║ ╚████║██║██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
Edition:
## 28/07/2026 by Tsukini
File Name:
## const.py
File Description:
## Different const used in the python scripts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
##### Import #####
# Import that can't be in the try
from sys import exit, stderr
# Import that can be checked
try:
from dataclasses import dataclass
from typing import ClassVar
except ImportError as e:
stderr.write(f"Import Error ({__file__}): {e}\n")
exit(255) # Special exit code (only place used)
# Check if the program is imported and not call
if __name__ == "__main__":
stderr.write(f"The {__file__} can only be imported and not executed!\n")
exit(255) # Special exit code (only place used)
##### Const #####
@dataclass(frozen=True)
class Return():
"""
Return values
"""
OK: int = 0 # Return value upon success on a call function
KO: int = 1 # Return value upon fail on a call function
@dataclass(frozen=True)
class Error():
"""
Error values
"""
FATAL: bin = 0b1000 # Global error, the program whole execution won't be able to run after this (100% execution stop)
LOCAL: bin = 0b100 # Local error, the program local execution won't probably be able to run after this (some chance of execution stop)
ACTION: bin = 0b10 # Same~~ as Return.KO, a program action execution won't be able to run after this (low chance of execution stop)
@dataclass(frozen=True)
class Values:
"""
Different values wihtout a precise category
"""
# Default values
EXCEPTION_TYPE: ClassVar[dict[str, int]] = {
"None": 0b0001, # Forced to exist
"Fatal": 0b0010,
"Error": 0b0100,
"Warning": 0b1000,
}
# Limits
SIZE_MAX: int = 2**64 - 1 # size_t max on 64 bits machine
@dataclass(frozen=True)
class Files:
"""
Different files path
"""
REQUIREMENTS: str = "cmake/scripts/requirements.txt"
CONFIG_EXCEPTION: str = "cmake/config/exceptions/"
GENERATED_EXCEPTION_HEADER: str = "include/exception/generated_external_exception_header.hpp"
@dataclass(frozen=True)
class Names:
"""
Different names
"""
EXCEPTION_SCOPE: str = "utils::exception"
EXCEPTION_TYPE_ENUM: str = "Type"
# Sections
GUARD: str = ""
CODE_SECTION: str = "ExternalCode"
MESSAGES_SECTION: str = "ExternalMessages"
INFO_SECTION: str = "ExternalInfo"
RESTRICTION_SECTION: str = "ExternalRestriction"
##### Declaration #####
RETURN = Return()
ERROR = Error()
VALUES = Values()
FILES = Files()
NAMES = Names()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |