Skip to content

fix: improve CardActionHandler type safety and error handling - #208

Open
dajiaohuang wants to merge 1 commit into
larksuite:mainfrom
dajiaohuang:fix/card-handler-improvements
Open

fix: improve CardActionHandler type safety and error handling#208
dajiaohuang wants to merge 1 commit into
larksuite:mainfrom
dajiaohuang:fix/card-handler-improvements

Conversation

@dajiaohuang

Copy link
Copy Markdown

Summary

This PR improves the CardActionHandler in dispatcher/card.ts:

Changes

  1. Type Safety: Changed Function type to specific signature (data: any) => Promise<any> for:

    • cardHandler property
    • handles Map values
    • Constructor parameter
    • register method parameter
  2. Error Handling: Changed error handling to re-throw exceptions instead of silently swallowing them:

    • catch (e) now does throw e instead of return undefined
    • This allows callers to distinguish between successful undefined returns and errors

Why

  • Using Function type is too broad and loses type safety
  • Silent error swallowing makes debugging difficult as callers cannot tell if an operation failed or just returned undefined

- Replace generic Function type with explicit (data: any) => Promise<any> signature
- Re-throw caught errors instead of returning undefined, allowing callers to distinguish success from failure
@CLAassistant

CLAassistant commented Aug 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dajiaohuang
dajiaohuang force-pushed the fix/card-handler-improvements branch from ed8f464 to 765ddc1 Compare August 24, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants