🐛 fix(utils.ts): add try-catch blocks to handle errors in groupByFamily function

The try-catch blocks were added to handle errors that may occur when the function is called. This improves the robustness of the function and prevents it from crashing when an error occurs.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-27 19:49:18 -03:00
commit e5676337b5

View file

@ -830,10 +830,16 @@ export function groupByFamily(data, baseClasses) {
Object.keys(data).map((d) => {
Object.keys(data[d]).map((n) => {
if (
data[d][n].base_classes.some((r) => baseClasses.split("\n").includes(r))
) {
arrOfParent.push(d);
try {
if (
data[d][n].base_classes.some((r) =>
baseClasses.split("\n").includes(r)
)
) {
arrOfParent.push(d);
}
} catch (e) {
console.log(e);
}
});
});
@ -844,16 +850,20 @@ export function groupByFamily(data, baseClasses) {
Object.keys(data).map((d) => {
Object.keys(data[d]).map((n) => {
baseClasses.split("\n").forEach((tol) => {
data[d][n].base_classes.forEach((data) => {
if (tol == data) {
arrOfType.push({
family: d,
type: data,
});
}
try {
baseClasses.split("\n").forEach((tol) => {
data[d][n].base_classes.forEach((data) => {
if (tol == data) {
arrOfType.push({
family: d,
type: data,
});
}
});
});
});
} catch (e) {
console.log(e);
}
});
});