MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / _handleError

Method _handleError

packager/src/Server/index.js:780–813  ·  view source on GitHub ↗
(res: ServerResponse, bundleID: string, error: {
    status: number,
    type: string,
    description: string,
    filename: string,
    lineNumber: number,
    errors: Array<{description: string, filename: string, lineNumber: number}>,
  })

Source from the content-addressed store, hash-verified

778 }
779
780 _handleError(res: ServerResponse, bundleID: string, error: {
781 status: number,
782 type: string,
783 description: string,
784 filename: string,
785 lineNumber: number,
786 errors: Array<{description: string, filename: string, lineNumber: number}>,
787 }) {
788 res.writeHead(error.status || 500, {
789 'Content-Type': 'application/json; charset=UTF-8',
790 });
791
792 if (error.type === 'TransformError' ||
793 error.type === 'NotFoundError' ||
794 error.type === 'UnableToResolveError') {
795 error.errors = [{
796 description: error.description,
797 filename: error.filename,
798 lineNumber: error.lineNumber,
799 }];
800 res.end(JSON.stringify(error));
801
802 if (error.type === 'NotFoundError') {
803 delete this._bundles[bundleID];
804 }
805 } else {
806 console.error(error.stack || error);
807 res.end(JSON.stringify({
808 type: 'InternalError',
809 message: 'react-packager has encountered an internal error, ' +
810 'please check your terminal error output for more details',
811 }));
812 }
813 }
814
815 _getOptionsFromUrl(reqUrl: string): BundleOptions {
816 // `true` to parse the query param as an object.

Callers 1

processRequestMethod · 0.95

Calls 3

writeHeadMethod · 0.80
errorMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected