Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
109 lines (92 loc) · 2.48 KB

File metadata and controls

109 lines (92 loc) · 2.48 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* @emails react-core
* @flow
*/
import React from 'react';
import type {Node} from 'react';
function replaceArgs(msg: string, argList: Array<string>): string {
let argIdx = 0;
return msg.replace(/%s/g, function() {
const arg = argList[argIdx++];
return arg === undefined ? '[missing argument]' : arg;
});
}
// When the message contains a URL (like https://fb.me/react-refs-must-have-owner),
// make it a clickable link.
function urlify(str: string): Node {
const urlRegex = /(https:\/\/fb\.me\/[a-z\-]+)/g;
const segments = str.split(urlRegex);
return segments.map((message, i) => {
if (i % 2 === 1) {
return (
<a key={i} target="_blank" rel="noopener" href={message}>
{message}
</a>
);
}
return message;
});
}
// `?invariant=123&args[]=foo&args[]=bar`
// or `// ?invariant=123&args[0]=foo&args[1]=bar`
function parseQueryString(
search: string,
): ?{|code: string, args: Array<string>|} {
const rawQueryString = search.substring(1);
if (!rawQueryString) {
return null;
}
let code = '';
let args = [];
const queries = rawQueryString.split('&');
for (let i = 0; i < queries.length; i++) {
const query = decodeURIComponent(queries[i]);
if (query.indexOf('invariant=') === 0) {
code = query.slice(10);
} else if (query.indexOf('args[') === 0) {
args.push(query.slice(query.indexOf(']=') + 2));
}
}
return {args, code};
}
function ErrorResult(props: {|code: ?string, msg: string|}) {
const code = props.code;
const errorMsg = props.msg;
if (!code) {
return (
<p>
Cuando encuentres un error, recibirás un enlace a esta página para ese
error específico y te mostraremos el texto completo del error.
</p>
);
}
return (
<div>
<p>
<b>
El texto completo del error que acabas de encontrar es el siguiente:
</b>
</p>
<code>
<b>{urlify(errorMsg)}</b>
</code>
</div>
);
}
function ErrorDecoder(props: {|
errorCodesString: string,
location: {search: string},
|}) {
let code = null;
let msg = '';
const errorCodes = JSON.parse(props.errorCodesString);
const parseResult = parseQueryString(props.location.search || '');
if (parseResult != null) {
code = parseResult.code;
msg = replaceArgs(errorCodes[code], parseResult.args);
}
return <ErrorResult code={code} msg={msg} />;
}
export default ErrorDecoder;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.