MCPcopy Index your code
hub / github.com/QwikDev/qwik / codeToText

Function codeToText

packages/qwik/src/core/error/error.ts:4–57  ·  view source on GitHub ↗
(code: number, ...parts: any[])

Source from the content-addressed store, hash-verified

2import { qDev } from '../util/qdev';
3
4export const codeToText = (code: number, ...parts: any[]): string => {
5 if (qDev) {
6 // Keep one error, one line to make it easier to search for the error message.
7 const MAP = [
8 'Error while serializing class or style attributes', // 0
9 'Can not serialize a HTML Node that is not an Element', // 1
10 'Runtime but no instance found on element.', // 2
11 'Only primitive and object literals can be serialized', // 3
12 'Crash while rendering', // 4
13 'You can render over a existing q:container. Skipping render().', // 5
14 'Set property {{0}}', // 6
15 "Only function's and 'string's are supported.", // 7
16 "Only objects can be wrapped in 'QObject'", // 8
17 `Only objects literals can be wrapped in 'QObject'`, // 9
18 'QRL is not a function', // 10
19 'Dynamic import not found', // 11
20 'Unknown type argument', // 12
21 `Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.`, // 13
22 "Invoking 'use*()' method outside of invocation context.", // 14
23 'Cant access renderCtx for existing context', // 15
24 'Cant access document for existing context', // 16
25 'props are immutable', // 17
26 '<div> component can only be used at the root of a Qwik component$()', // 18
27 'Props are immutable by default.', // 19
28 `Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.\nSee https://qwik.dev/docs/core/tasks/#use-method-rules`, // 20
29 'Container is already paused. Skipping', // 21
30 '', // 22 -- unused
31 'When rendering directly on top of Document, the root node must be a <html>', // 23
32 'A <html> node must have 2 children. The first one <head> and the second one a <body>', // 24
33 'Invalid JSXNode type "{{0}}". It must be either a function or a string. Found:', // 25
34 'Tracking value changes can only be done to useStore() objects and component props', // 26
35 'Missing Object ID for captured object', // 27
36 'The provided Context reference "{{0}}" is not a valid context created by createContextId()', // 28
37 '<html> is the root container, it can not be rendered inside a component', // 29
38 'QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.', // 30
39 'QRLs can not be dynamically resolved, because it does not have a chunk path', // 31
40 'The JSX ref attribute must be a Signal', // 32
41 ];
42 let text = MAP[code] ?? '';
43 if (parts.length) {
44 text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
45 let v = parts[index];
46 if (v && typeof v === 'object' && v.constructor === Object) {
47 v = JSON.stringify(v).slice(0, 50);
48 }
49 return v;
50 });
51 }
52 return `Code(${code}): ${text}`;
53 } else {
54 // cute little hack to give roughly the correct line number. Update the line number if it shifts.
55 return `Code(${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
56 }
57};
58
59export const QError_stringifyClassOrStyle = 0;
60export const QError_cannotSerializeNode = 1;

Callers 3

_setPropertyFunction · 0.90
trackFunction · 0.90
qErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…