moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.17k stars 587 forks source link

Improve broker error handler types #1286

Closed shawnmcknight closed 5 months ago

shawnmcknight commented 5 months ago

:memo: Description

The errorHandler option that can be supplied to the service broker options has loose type definitions for the info parameter. In one case it is defined as any, and in the other it is defined as GenericObject (i.e. Record<string,any>). The signature of the callers to the errorHandler is variable, but it falls into two distinct categories: when called from the error handler middleware and when called from other broker workflows. These results in two possible types for the info parameter.

This PR updates the type definitions to be more specific about the types for the info parameter for the broker's errorHandler option.

:dart: Relevant issues

None

:gem: Type of change

:vertical_traffic_light: How Has This Been Tested?

I patched these changes into my repository and then created a new error handler function which used the info parameter.

:checkered_flag: Checklist: