How to use the @lwc/errors.ParserDiagnostics.GENERIC_PARSING_ERROR function in @lwc/errors

To help you get started, we’ve selected a few @lwc/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / lwc / packages / @lwc / template-compiler / src / parser / index.ts View on Github external
type: IRAttributeType.Boolean,
                    value: true,
                };
            } else {
                return {
                    name,
                    location,
                    type: IRAttributeType.String,
                    value,
                };
            }
        } catch (error) {
            // Removes the attribute, if impossible to parse it value.
            removeAttribute(el, name);
            addDiagnostic(
                normalizeToDiagnostic(ParserDiagnostics.GENERIC_PARSING_ERROR, error, {
                    location: normalizeLocation(location),
                })
            );
        }
    }
github salesforce / lwc / packages / @lwc / template-compiler / src / index.ts View on Github external
let code = '';
    const warnings: CompilerDiagnostic[] = [];
    try {
        const parsingResults = parseTemplate(source, state);
        warnings.push(...parsingResults.warnings);

        const hasParsingError = parsingResults.warnings.some(
            warning => warning.level === DiagnosticLevel.Error
        );

        if (!hasParsingError && parsingResults.root) {
            const output = generate(parsingResults.root, state);
            code = output.code;
        }
    } catch (error) {
        const diagnostic = normalizeToDiagnostic(ParserDiagnostics.GENERIC_PARSING_ERROR, error);
        diagnostic.message = `Unexpected compilation error: ${diagnostic.message}`;
        warnings.push(diagnostic);
    }

    return {
        code,
        warnings,
    };
}
export function compileToFunction(source: string): Function {