mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
framework: show step error detail
This commit is contained in:
2 files changed
+2
-5
No files matched your search
@@ -528,7 +528,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
else if (typeof h[step] === 'function') control = await h[step](args);
|
else if (typeof h[step] === 'function') control = await h[step](args);
|
||||||
if (control) {
|
if (control) {
|
||||||
const index = steps.findIndex((i) => control === i);
|
const index = steps.findIndex((i) => control === i);
|
||||||
if (index === -1) throw new Error(`Invalid control: ${control}`);
|
if (index === -1) throw new Error(`Invalid control: ${control} (after step ${step})`);
|
||||||
if (index <= current) {
|
if (index <= current) {
|
||||||
logger.warn('Returning to previous step is not recommended:', step, '->', control);
|
logger.warn('Returning to previous step is not recommended:', step, '->', control);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
// https://github.com/waylonflinn/markdown-it-katex/blob/master/index.js
|
// https://github.com/waylonflinn/markdown-it-katex/blob/master/index.js
|
||||||
import { Logger } from 'hydrooj';
|
|
||||||
import katex from 'katex';
|
import katex from 'katex';
|
||||||
|
|
||||||
const logger = new Logger('katex');
|
|
||||||
|
|
||||||
function isValidDelim(state, pos) {
|
function isValidDelim(state, pos) {
|
||||||
const max = state.posMax;
|
const max = state.posMax;
|
||||||
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
||||||
@@ -118,7 +115,7 @@ export default function plugin(md) {
|
|||||||
latex = latex.replace(/\\def{\\([a-zA-Z0-9]+)}/g, '\\def\\$1');
|
latex = latex.replace(/\\def{\\([a-zA-Z0-9]+)}/g, '\\def\\$1');
|
||||||
return katex.renderToString(latex, options);
|
return katex.renderToString(latex, options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (options.throwOnError) logger.error(error);
|
if (options.throwOnError) console.error(error);
|
||||||
return `<p class='${displayMode ? 'katex-block ' : ''}katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</p>`;
|
return `<p class='${displayMode ? 'katex-block ' : ''}katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</p>`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user