-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(backend): backend error handling strategy #89
Conversation
… and remove code block fences
Caution Review failedThe pull request is closed. Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
backend/src/build-system/context.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-prettier". (The package "eslint-plugin-prettier" was not found when loaded as a Node module from the directory "/backend".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-prettier" was referenced from the config file in "backend/.eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. WalkthroughThis pull request introduces a comprehensive error handling and validation framework across multiple build system handlers. The changes focus on implementing a robust error management strategy by introducing new error classes in Changes
Sequence DiagramsequenceDiagram
participant Handler
participant RetryHandler
participant ModelService
Handler->>RetryHandler: Attempt operation
alt Operation fails with retryable error
RetryHandler->>ModelService: Retry operation
alt Retry successful
ModelService-->>RetryHandler: Return result
RetryHandler-->>Handler: Return result
else Max retries exceeded
RetryHandler-->>Handler: Throw final error
end
else Operation successful
ModelService-->>Handler: Return result
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (18)
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…re-backend-error-handling-strategy
backend/src/build-system/handlers/ux/sitemap-structure/index.ts
Outdated
Show resolved
Hide resolved
1446ee3
to
169556e
Compare
…hub.com/Sma1lboy/codefox into feature-backend-error-handling-strategy
…re-backend-error-handling-strategy
…hub.com/Sma1lboy/codefox into feature-backend-error-handling-strategy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this change please, or put all into test-utils
@@ -17,12 +21,6 @@ export class FileStructureHandler implements BuildHandler<FileStructOutput> { | |||
readonly id = 'op:FILE:STRUCT'; | |||
private readonly logger: Logger = new Logger('FileStructureHandler'); | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
this.name = 'ModelTimeoutError'; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding long description for each erorr
error instanceof RateLimitExceededError | ||
) { | ||
throw error; // Retryable errors will be handled externally. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try {
modelResponse = await this.callModel(context, backendCodePrompt);
} catch (error) {
throw error
}
model: 'gpt-4o-mini', | ||
messages: [{ content: filePrompt, role: 'system' }], | ||
}); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this error handle with some issue just throw ModelUnavlible right now. non retry
await fs.writeFile(filePath, newContent, 'utf-8'); | ||
this.logger.log(`Successfully modified ${fileName}`); | ||
} catch (error) { | ||
this.handleFileProcessingError(fileName, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need extract this func
* @param context The builder context. | ||
* @param prompt The generated prompt. | ||
*/ | ||
private async callModel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if using callModel anywhere make it as export function and reuse it
* Calls the language model to generate database requirements. | ||
* @param prompt The generated prompt. | ||
*/ | ||
private async callModel(prompt: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
success: true, | ||
data: schemaContent, | ||
}; | ||
private handleModelErrors(error: any, stage: string): never { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito. remove this
Summary by CodeRabbit
Release Notes
Error Handling
Code Structure
Retry Mechanism
Testing