Skip to content

Commit

Permalink
refactor(core): improve error handling in ChatInterface
Browse files Browse the repository at this point in the history
- Update error handling logic for better readability and performance
- Use conditional statement to check for ChatLunaError instance before throwing
  • Loading branch information
dingyi222666 committed Nov 25, 2024
1 parent 9b3b549 commit 7e7d612
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/llm-core/chat/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ export class ChatInterface {
await this.disableConfig(config)
}

throw error instanceof ChatLunaError
? error
: new ChatLunaError(ChatLunaErrorCode.UNKNOWN_ERROR, error as Error)
if (error instanceof ChatLunaError) {
throw error
}

throw new ChatLunaError(ChatLunaErrorCode.UNKNOWN_ERROR, error as Error)
}

private async disableConfig(config: ClientConfigWrapper): Promise<void> {
Expand Down

0 comments on commit 7e7d612

Please sign in to comment.