RN: Improve Error for Invalid processFilter Values (#46271)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46271

Improves the error thrown when an invalid value is supplied to `processFilter`. Without this, the error thrown would look something like:

> TypeError: … is not iterable

Changelog:
[General][Changed] - Improved error message for invalid filter values

Reviewed By: jorge-cab

Differential Revision: D62011191

fbshipit-source-id: 5594eeaf2b9174af14cc9e4daa275ae72974e597
This commit is contained in:
Tim Yung
2024-08-30 15:50:00 -07:00
committed by Facebook GitHub Bot
parent b25d6c8d1b
commit 4094ce0718
@@ -82,7 +82,7 @@ export default function processFilter(
}
}
}
} else {
} else if (Array.isArray(filter)) {
for (const filterFunction of filter) {
const [filterName, filterValue] = Object.entries(filterFunction)[0];
if (filterName === 'dropShadow') {
@@ -109,6 +109,8 @@ export default function processFilter(
}
}
}
} else {
throw new TypeError(`${typeof filter} filter is not a string or array`);
}
return result;