Is your feature request related to a problem? Please describe.
When you have to handle an error in a TypeScript try/catch block, you need to verify that the parameter in the catch block is an Error before accessing any properties on it. If the value thrown is not instanceof Error we can just throw it as-is. We have this pattern in numerous places in the codebase.
Describe the solution you'd like
Implement a helper function to reduce duplicating this pattern.
Describe alternatives you've considered
Can continue adopting this pattern:
try {
// some action that can throw error
} catch (err) {
if (err instanceof Error) {
// transform or doing something special
}
throw err;
}
But this pattern can be easily de-duplicated
Additional context
Came up while reviewing code in zowe/zowex
Is your feature request related to a problem? Please describe.
When you have to handle an error in a TypeScript
try/catchblock, you need to verify that the parameter in thecatchblock is anErrorbefore accessing any properties on it. If the value thrown is notinstanceof Errorwe can just throw it as-is. We have this pattern in numerous places in the codebase.Describe the solution you'd like
Implement a helper function to reduce duplicating this pattern.
Describe alternatives you've considered
Can continue adopting this pattern:
But this pattern can be easily de-duplicated
Additional context
Came up while reviewing code in zowe/zowex