Files
flipper/desktop/flipper-plugin-core/src/utils/safeStringify.tsx
Pascal Hartig bf2f1283d3 Unbreak error logging
Summary:
*Potentially.

A big thanks to lblasa and aigoncharov for helping with debugging. Looking at
`ptail -f errorlog_flipper_javascript` reveals that messages now include a spurious amount of unescaped newlines. E.g. P768993195

From memory, these were not there when I wrote the categorizer when I was able to copy-paste from ptail to the unit tests.

D44729490 added prettifying to the results inadvertently.

Reviewed By: lblasa

Differential Revision: D46685543

fbshipit-source-id: 98da5eff92900042fc5306ca5d5652d8940ff2e1
2023-06-13 08:17:03 -07:00

17 lines
393 B
TypeScript

/**
* 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.
*
* @format
*/
export function safeStringify(value: any, space: number = 2) {
try {
return JSON.stringify(value, null, space);
} catch (e) {
return '<Failed to serialize: ' + e + '>';
}
}