UNPKG

yhtml5-test

Version:

A test framework for front-end projects

54 lines (46 loc) 1.71 kB
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React from 'react'; import Header from '../components/Header'; import StackTrace from './StackTrace'; var wrapperStyle = { display: 'flex', flexDirection: 'column' }; function RuntimeError(_ref) { var errorRecord = _ref.errorRecord, launchEditorEndpoint = _ref.launchEditorEndpoint; var error = errorRecord.error, unhandledRejection = errorRecord.unhandledRejection, contextSize = errorRecord.contextSize, stackFrames = errorRecord.stackFrames; var errorName = unhandledRejection ? 'Unhandled Rejection (' + error.name + ')' : error.name; // Make header prettier var message = error.message; var headerText = message.match(/^\w*:/) || !errorName ? message : errorName + ': ' + message; headerText = headerText // TODO: maybe remove this prefix from fbjs? // It's just scaring people .replace(/^Invariant Violation:\s*/, '') // This is not helpful either: .replace(/^Warning:\s*/, '') // Break the actionable part to the next line. // AFAIK React 16+ should already do this. .replace(' Check the render method', '\n\nCheck the render method').replace(' Check your code at', '\n\nCheck your code at'); return React.createElement( 'div', { style: wrapperStyle }, React.createElement(Header, { headerText: headerText }), React.createElement(StackTrace, { stackFrames: stackFrames, errorName: errorName, contextSize: contextSize, launchEditorEndpoint: launchEditorEndpoint }) ); } export default RuntimeError;