Files
simply_cpq/website/node_modules/@base-ui/utils/formatErrorMessage.mjs
T
2026-08-07 21:39:30 +02:00

26 lines
1.2 KiB
JavaScript

/**
* Creates a formatErrorMessage function with a custom URL and prefix.
* @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
* @param prefix - The prefix for the error message (e.g., 'Base UI')
* @returns A function that formats error messages with the given URL and prefix
*/
export function createFormatErrorMessage(baseUrl, prefix) {
return function formatErrorMessage(code, ...args) {
const url = new URL(baseUrl);
url.searchParams.set('code', code.toString());
args.forEach(arg => url.searchParams.append('args[]', arg));
return `${prefix} error #${code}; visit ${url} for the full message.`;
};
}
/**
* WARNING: Don't import this directly. It's imported by the code generated by
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
* constructors to ensure the plugin works as expected. Supported patterns include:
* throw new Error('My message');
* throw new Error(`My message: ${foo}`);
* throw new Error(`My message: ${foo}` + 'another string');
* ...
*/
const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
export default formatErrorMessage;