33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.createFormatErrorMessage = createFormatErrorMessage;
|
|
exports.default = void 0;
|
|
/**
|
|
* 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
|
|
*/
|
|
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');
|
|
var _default = exports.default = formatErrorMessage; |