/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/community-cli-plugin/src/utils/errors.js
38 строк
1 KB
Tim Yung
RN: Delete `@oncall` Annotations (#51416)
18 май 2025, 02:18
18 май 2025, 02:18
84de8a0
Код
Авторство
О чём код?
/** * 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();