I have a array with different and unique errors as this:
[
"ClientError('Bad Request: Not authorized to view user',)",
"ConnectionResetError(104, 'Connection reset by peer')",
"CursorNotFound('Cursor not found, cursor id: 195552090717',)",
"CursorNotFound('Cursor not found, cursor id: 193743299994',)",
"CursorNotFound('Cursor not found, cursor id: 194974042489',)"
]
I have only 3 errors but since the cursor id
is different the functions create more errors. How can group CursorNotFound
errors in one group?
I want to get something like this:
[
"ClientError('Bad Request: Not authorized to view user',)",
"ConnectionResetError(104, 'Connection reset by peer')",
"groupA": [
"CursorNotFound('Cursor not found, cursor id: 195552090717',)",
"CursorNotFound('Cursor not found, cursor id: 193743299994',)",
"CursorNotFound('Cursor not found, cursor id: 194974042489',)"
]
]
Can indexof
serve this?
let allError = [];
_array.forEach(element => allError.push(element.error));
let uniq = Array.from(new Set(allError));
console.log(uniq);