Skip to content

Commit de7e643

Browse files
authored
Remove $FlowFixMe[sketchy-null-string] (errors.js) (#59976)
Summary: Replace the optional original error stack's `||` fallback with an explicit null-or-empty ternary. Read the stack getter once in the Error branch and preserve the direct string branch, including `''`. Null/undefined/empty stacks still evaluate the existing `''.split('\n').slice(0, 2).join('\n')` fallback; nonempty stacks are unchanged. Do not alter the fallback's existing behavior. Changelog: [Internal] Differential Revision: D129900981 Pull Request resolved: #59976
1 parent aedc2e7 commit de7e643

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • packages/community-cli-plugin/src/utils

‎packages/community-cli-plugin/src/utils/errors.js‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ export class CLIError extends Error {
1616
constructor(msg: string, originalError?: Error | string) {
1717
super(inlineString(msg));
1818
if (originalError != null) {
19-
this.stack =
20-
typeof originalError === 'string'
21-
? originalError
22-
: // $FlowFixMe[sketchy-null-string]
23-
originalError.stack || ''.split('\n').slice(0, 2).join('\n');
19+
if (typeof originalError === 'string') {
20+
this.stack = originalError;
21+
} else {
22+
const originalStack = originalError.stack;
23+
this.stack =
24+
originalStack == null || originalStack === ''
25+
? ''.split('\n').slice(0, 2).join('\n')
26+
: originalStack;
27+
}
2428
} else {
2529
// When the "originalError" is not passed, it means that we know exactly
2630
// what went wrong and provide means to fix it. In such cases showing the

0 commit comments

Comments
 (0)