From addb2bccc8adeb5a778aeef7feebf92d46f85b13 Mon Sep 17 00:00:00 2001 From: Janpot <2109932+Janpot@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:06:24 +0100 Subject: [PATCH 1/2] [code-infra] CC suggestions for better error messages --- packages/mui-lab/src/TabList/TabList.js | 7 ++++++- packages/mui-lab/src/TabPanel/TabPanel.js | 7 ++++++- packages/mui-material/src/styles/createThemeWithVars.js | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/mui-lab/src/TabList/TabList.js b/packages/mui-lab/src/TabList/TabList.js index 98f17db639e25e..f34ebf3039cda4 100644 --- a/packages/mui-lab/src/TabList/TabList.js +++ b/packages/mui-lab/src/TabList/TabList.js @@ -8,7 +8,12 @@ const TabList = React.forwardRef(function TabList(props, ref) { const { children: childrenProp, ...other } = props; const context = useTabContext(); if (context === null) { - throw new TypeError('No TabContext provided'); + throw /* minify-error */ new Error( + 'MUI: No TabContext provided. ' + + 'TabList must be used within a TabContext. ' + + 'Wrap your Tabs with . ' + + 'See https://mui.com/material-ui/react-tabs/#experimental-api for more info.', + ); } const children = React.Children.map(childrenProp, (child) => { if (!React.isValidElement(child)) { diff --git a/packages/mui-lab/src/TabPanel/TabPanel.js b/packages/mui-lab/src/TabPanel/TabPanel.js index 51ec59d6a0cc46..638c6b7eb9d86e 100644 --- a/packages/mui-lab/src/TabPanel/TabPanel.js +++ b/packages/mui-lab/src/TabPanel/TabPanel.js @@ -37,7 +37,12 @@ const TabPanel = React.forwardRef(function TabPanel(inProps, ref) { const context = useTabContext(); if (context === null) { - throw new TypeError('No TabContext provided'); + throw /* minify-error */ new Error( + 'MUI: No TabContext provided. ' + + 'TabPanel must be used within a TabContext. ' + + 'Wrap your TabPanel with . ' + + 'See https://mui.com/material-ui/react-tabs/#experimental-api for more info.', + ); } const id = getPanelId(context, value); const tabId = getTabId(context, value); diff --git a/packages/mui-material/src/styles/createThemeWithVars.js b/packages/mui-material/src/styles/createThemeWithVars.js index 0a2ba6d4c0c36f..c00f28fde6cecf 100644 --- a/packages/mui-material/src/styles/createThemeWithVars.js +++ b/packages/mui-material/src/styles/createThemeWithVars.js @@ -162,7 +162,8 @@ export default function createThemeWithVars(options = {}, ...args) { if (!defaultScheme) { throw /* minify-error */ new Error( - `MUI: The \`colorSchemes.${defaultColorScheme}\` option is either missing or invalid.`, + `MUI: The \`colorSchemes.${defaultColorScheme}\` option is either missing or invalid. ` + + 'Ensure the default color scheme is defined in colorSchemes with a valid palette configuration.', ); } From 1de66c97614bffaba0156f263cb51193756a7f4d Mon Sep 17 00:00:00 2001 From: Janpot <2109932+Janpot@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:26:59 +0100 Subject: [PATCH 2/2] fix error-codes.json --- docs/public/static/error-codes.json | 4 +++- packages/mui-lab/src/TabList/TabList.js | 2 +- packages/mui-lab/src/TabPanel/TabPanel.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/public/static/error-codes.json b/docs/public/static/error-codes.json index 5e86ee26ea6822..b7c75954e92719 100644 --- a/docs/public/static/error-codes.json +++ b/docs/public/static/error-codes.json @@ -19,5 +19,7 @@ "18": "MUI: The provided shorthand %s is invalid. The format should be `@` or `@/`.\nFor example, `@sm` or `@600` or `@40rem/sidebar`.", "19": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150.", "20": "MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.", - "21": "MUI: The `colorSchemes.%s` option is either missing or invalid." + "24": "MUI: The `colorSchemes.%s` option is either missing or invalid. Ensure the default color scheme is defined in colorSchemes with a valid palette configuration.", + "22": "MUI: No TabContext provided. TabPanel must be used within a TabContext. Wrap your TabPanel with . See https://mui.com/material-ui/react-tabs/#experimental-api for more info.", + "23": "MUI: No TabContext provided. TabList must be used within a TabContext. Wrap your Tabs with . See https://mui.com/material-ui/react-tabs/#experimental-api for more info." } diff --git a/packages/mui-lab/src/TabList/TabList.js b/packages/mui-lab/src/TabList/TabList.js index f34ebf3039cda4..49b921a21af367 100644 --- a/packages/mui-lab/src/TabList/TabList.js +++ b/packages/mui-lab/src/TabList/TabList.js @@ -8,7 +8,7 @@ const TabList = React.forwardRef(function TabList(props, ref) { const { children: childrenProp, ...other } = props; const context = useTabContext(); if (context === null) { - throw /* minify-error */ new Error( + throw /* minify-error */ new TypeError( 'MUI: No TabContext provided. ' + 'TabList must be used within a TabContext. ' + 'Wrap your Tabs with . ' + diff --git a/packages/mui-lab/src/TabPanel/TabPanel.js b/packages/mui-lab/src/TabPanel/TabPanel.js index 638c6b7eb9d86e..8e5f94d2d3ae6a 100644 --- a/packages/mui-lab/src/TabPanel/TabPanel.js +++ b/packages/mui-lab/src/TabPanel/TabPanel.js @@ -37,7 +37,7 @@ const TabPanel = React.forwardRef(function TabPanel(inProps, ref) { const context = useTabContext(); if (context === null) { - throw /* minify-error */ new Error( + throw /* minify-error */ new TypeError( 'MUI: No TabContext provided. ' + 'TabPanel must be used within a TabContext. ' + 'Wrap your TabPanel with . ' +