Skip to content

Commit

Permalink
Update ErrorTreeItem.ts for better readability
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
marwan37 and coderabbitai[bot] authored Apr 3, 2024
1 parent a9eca07 commit 5edbb5c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/views/activityBar/common/ErrorTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,20 @@ export const createErrorItem = (error: any): TreeItem[] => {
*/
export const createAuthErrorItem = (errorMessage: string): ErrorTreeItem[] => {
const parts = errorMessage.split(':').map(part => part.trim());

let generalError = '';
let detailedError = '';
let actionSuggestion = '';
let [generalError, detailedError, actionSuggestion] = ['', '', ''];

if (parts.length > 2) {
generalError = parts[0]; // "Failed to retrieve pipeline runs"
detailedError = parts[1] + ': ' + (parts[2].split('.')[0] || '').trim(); // "Authentication error: error decoding access token"
actionSuggestion = (parts[2].split('. ')[1] || '').trim(); // "You may need to rerun zenml connect"
generalError = parts[0];
detailedError = `${parts[1]}: ${(parts[2].split('.')[0] || '').trim()}`;
actionSuggestion = (parts[2].split('. ')[1] || '').trim();
}

const errorItems: ErrorTreeItem[] = [];

if (detailedError) {
errorItems.push(new ErrorTreeItem(parts[1], detailedError.split(':')[1].trim()));
}

if (actionSuggestion) {
errorItems.push(new ErrorTreeItem(actionSuggestion, ''));
}

return errorItems;
};

0 comments on commit 5edbb5c

Please sign in to comment.