BankFeedback lived under entities/bank-card/ui but pulled apiErrorCode from @/shared/api, which dragged the entire api layer (openapi-fetch, openapi-react-query, @tanstack/react-query, client, problem-details, resource-query) into any Storybook story that imported a sibling view, breaking stories-must-not-reach-application-data. Move the local 'extract code from unknown' helper into the entity and consume it from BankFeedback. The shared helper stays in shared/api for the rest of the app.
8 lines
191 B
TypeScript
8 lines
191 B
TypeScript
function errorCode(error: unknown): string | undefined {
|
|
return typeof error === "object" && error !== null && "code" in error
|
|
? String(error.code)
|
|
: undefined;
|
|
}
|
|
|
|
export { errorCode };
|