Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions packages/core/src/html/includePanelProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function _checkAndWarnFileExists(element: MbNode, context: Context, actualFilePa
});
const error = new Error(
`No such file: ${actualFilePath}\nMissing reference in ${context.cwf}`);
logger.error(error);
logger.error(error.message);

createErrorNode(element, error);
return false;
Expand Down Expand Up @@ -187,7 +187,7 @@ export function processInclude(node: MbNode, context: Context, pageSources: Page
getNextFootnodeNumber: () => number = buildGetNextFootnodeNumber()): Context {
if (_.isEmpty(node.attribs.src)) {
const error = new Error(`Empty src attribute in include in: ${context.cwf}`);
logger.error(error);
logger.error(error.message);
cheerio(node).replaceWith(createErrorNode(node, error));
return context;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ export function processInclude(node: MbNode, context: Context, pageSources: Page
if (actualContentOrNull === null && !isOptional) {
const error = new Error(`No such segment '${hash}' in file: ${actualFilePath}\n`
+ `Missing reference in ${context.cwf}`);
logger.error(error);
logger.error(error.message);

actualContent = cheerio.html(createErrorNode(node, error));
} else if (actualContentOrNull === '') {
Expand All @@ -294,7 +294,7 @@ export function processInclude(node: MbNode, context: Context, pageSources: Page

if (childContext.hasExceededMaxCallstackSize()) {
const error = new CyclicReferenceError(childContext.callStack);
logger.error(error);
logger.error(error.message);
cheerio(node).replaceWith(createErrorNode(node, error));
return context;
}
Expand All @@ -318,8 +318,8 @@ export function processPopoverSrc(node: MbNode, context: Context, pageSources: P
}

if (_.isEmpty(node.attribs.src)) {
const error = new Error(`Empty src attribute in include in: ${context.cwf}`);
logger.error(error);
const error = new Error(`Empty src attribute in popover in: ${context.cwf}`);
logger.error(error.message);
cheerio(node).replaceWith(createErrorNode(node, error));
return context;
}
Expand All @@ -335,7 +335,12 @@ export function processPopoverSrc(node: MbNode, context: Context, pageSources: P
// No need to process url contents
if (isUrl) {
const error = new Error('URLs are not allowed in the \'src\' attribute');
logger.error(error);
logger.error(`${error.message}
File: ${context.cwf}
URL provided: ${node.attribs.src}

Please check the \`src\` attribute in the popover element.
Ensure it doesn't contain a URL (e.g., "http://www.example.com").`);
cheerio(node).replaceWith(createErrorNode(node, error));
return context;
}
Expand Down Expand Up @@ -369,7 +374,7 @@ export function processPopoverSrc(node: MbNode, context: Context, pageSources: P
if (actualContent === '') {
const error = new Error(`No such segment '${hash}' in file: ${actualFilePath}\n`
+ `Missing reference in ${context.cwf}`);
logger.error(error);
logger.error(error.message);

cheerio(node).replaceWith(createErrorNode(node, error));

Expand All @@ -384,7 +389,7 @@ export function processPopoverSrc(node: MbNode, context: Context, pageSources: P

if (childContext.hasExceededMaxCallstackSize()) {
const error = new CyclicReferenceError(childContext.callStack);
logger.error(error);
logger.error(error.message);
Comment thread
tlylt marked this conversation as resolved.
cheerio(node).replaceWith(createErrorNode(node, error));
return context;
}
Expand Down