feat: add custom error classes for better error handling#16
Open
alobroke wants to merge 1 commit intobug0inc:mainfrom
Open
feat: add custom error classes for better error handling#16alobroke wants to merge 1 commit intobug0inc:mainfrom
alobroke wants to merge 1 commit intobug0inc:mainfrom
Conversation
- Add PassmarkError base class with error code property - Add StepExecutionError for step execution failures (with stepDescription field) - Add AIModelError for AI provider/model failures - Add CacheError for Redis/cache failures (ready for future use) - Add ConfigurationError for missing env vars and config - Add ValidationError for invalid inputs (missing scripts, placeholders) - Replace all generic Error instances across index.ts, models.ts, data-cache.ts, email.ts - Export all error classes from public API so users can do instanceof checks Closes bug0inc#9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9
What
Creates
src/errors.tswith a custom error hierarchy for Passmark.New classes:
PassmarkError— base class, all errors extend this. Has acodeproperty for programmatic identificationStepExecutionError— step failed during AI or cached execution. IncludesstepDescriptionfieldAIModelError— AI provider/model failure or unknown providerCacheError— Redis/cache failures (ready for future use as Redis handling grows)ConfigurationError— missing API keys or environment variablesValidationError— invalid inputs (missing script content, missing executionId/projectId)Why
All errors were generic
Errorinstances, making it impossible for users to programmatically distinguish between different failure types. Now users can do:Changes
src/errors.ts— new file with all error classessrc/index.ts— usesStepExecutionErrorandValidationErrorsrc/models.ts— usesConfigurationErrorandAIModelErrorsrc/data-cache.ts— usesConfigurationErrorandValidationErrorsrc/email.ts— usesConfigurationErrorandAIModelError