[data grid] Introduce throwMissingRowError utility for consistent error handling#22325
Open
sai6855 wants to merge 2 commits intomui:masterfrom
Open
[data grid] Introduce throwMissingRowError utility for consistent error handling#22325sai6855 wants to merge 2 commits intomui:masterfrom
sai6855 wants to merge 2 commits intomui:masterfrom
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes the “missing row” error throw logic into a shared throwMissingRowError(id) utility (exported from gridRowsUtils.ts) and replaces multiple duplicated throw new Error(...) call sites across the Data Grid community and premium codepaths.
Changes:
- Add
throwMissingRowError(id: GridRowId): nevertogridRowsUtils.tsand export it via@mui/x-data-grid/internals. - Replace several inline missing-row
throw new Error(...)statements withthrowMissingRowError(...)in row/params hooks. - Update premium features to reuse the centralized helper via internals exports.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/x-data-grid/src/internals/index.ts | Re-exports throwMissingRowError through the community internals barrel. |
| packages/x-data-grid/src/hooks/features/rows/useGridRowsOverridableMethods.ts | Uses throwMissingRowError for missing source/target nodes in row reordering. |
| packages/x-data-grid/src/hooks/features/rows/useGridRows.ts | Uses throwMissingRowError when toggling group expansion for a non-existent node. |
| packages/x-data-grid/src/hooks/features/rows/useGridParamsOverridableMethods.ts | Uses throwMissingRowError for getCellValue when the row is missing. |
| packages/x-data-grid/src/hooks/features/rows/useGridParamsApi.ts | Uses throwMissingRowError and removes the local MissingRowIdError class. |
| packages/x-data-grid/src/hooks/features/rows/gridRowsUtils.ts | Introduces the throwMissingRowError helper. |
| packages/x-data-grid-premium/src/hooks/features/rows/useGridRowsOverridableMethods.ts | Switches to throwMissingRowError for missing nodes during row reorder operations. |
| packages/x-data-grid-premium/src/hooks/features/export/serializer/excelSerializer.ts | Uses throwMissingRowError when row/rowNode are missing during Excel serialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
19
| import { throwMissingRowError } from './gridRowsUtils'; | ||
| import type { GridConfiguration } from '../../../models/configuration/gridConfiguration'; | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: sai chand <60743144+sai6855@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidate the duplicated throw new Error(`MUI X: No row with id #${id} found`) pattern into a single
throwMissingRowError(id)helper exported fromgridRowsUtils.ts. Replaces 10 call sites (8 barethrow+ 2 file-private