Files
react-native/Libraries/Core/ExtendedError.js
T
Gijs Weterings ca1c3f9080 Add ability to add custom extraData to errors passed to ExceptionsManager
Summary:
This adds an option to the Error Reporting pipeline of React Native to attach custom extra data to Exceptions passed to the native ExceptionsManager. This allows for error logging abstractions such as Meta's FBLogger to attach extra fields to the reported error. This can help with more detailed error reports without having to stringify all data in the error message.

Note: The field (which is technically on ExtendedError) is keyed using a Symbol. This is to make sure that any use of this ability is extremely deliberate, as (accidentally) adding tons of data (or unserializable data) can cause issues we send down the data to the native ExceptionsManager implementation. Data sent using this method should be strictly controlled, hence opting in is a concious effort using the symbol in ExceptionsManager

Changelog:
[Internal] [Added] - Ability to add custom data to extraData field of exceptions passed to the ExceptionsManager

Reviewed By: yungsters

Differential Revision: D36099191

fbshipit-source-id: ce3f0dae52acd742de98b71868323c5878eaa677
2022-08-15 11:05:58 -07:00

22 lines
692 B
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
* @format
*/
export type ExtendedError = Error &
interface {
jsEngine?: string,
preventSymbolication?: boolean,
componentStack?: string,
isComponentError?: boolean,
type?: string,
// Note: A field keyed by the Symbol ExceptionsManager.decoratedExtraDataKey is also read from ExtendedErrors.
// This field isn't documented in the types as Flow does not support this usecase, but it's effectively:
// [decoratedExtraDataKey]?: {[string]: mixed},
};