Files
Tim Yung 84de8a075e RN: Delete @oncall Annotations (#51416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51416

Deletes `oncall` annotations from the `facebook/react-native` repository.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D74902524

fbshipit-source-id: 32a6a5b2ff27281792d572f151e2b094d9a79029
2025-05-17 16:18:05 -07:00

39 lines
1.2 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
/**
* A custom Error that creates a single-lined message to match current styling inside CLI.
* Uses original stack trace when `originalError` is passed or erase the stack if it's not defined.
*/
export class CLIError extends Error {
constructor(msg: string, originalError?: Error | string) {
super(inlineString(msg));
if (originalError != null) {
this.stack =
typeof originalError === 'string'
? originalError
: originalError.stack || ''.split('\n').slice(0, 2).join('\n');
} else {
// When the "originalError" is not passed, it means that we know exactly
// what went wrong and provide means to fix it. In such cases showing the
// stack is an unnecessary clutter to the CLI output, hence removing it.
this.stack = '';
}
}
}
/**
* Raised when we're unable to find a package.json
*/
export class UnknownProjectError extends Error {}
export const inlineString = (str: string = ''): string =>
str.replace(/(\s{2,})/gm, ' ').trim();