Skip to content

Commit

Permalink
Error Handlinig
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvillain committed Jan 25, 2021
1 parent bc4b155 commit dc33ed7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [1.0.2]

- Added Logo
- Added Logo

## [1.0.3]

- Better Error Handling
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "motivate-me",
"displayName": "Motivate Me",
"description": "",
"version": "1.0.2",
"version": "1.0.3",
"icon": "images/logo.png",
"publisher": "TekeshwarSingh",
"repository": "https://github.com/tsvillain/MotivateMe",
Expand Down
16 changes: 13 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ function updateStatusBarItem(): void {


async function showQuote() {
const response = await fetch(apiUrl);
const json = await response.json();
vscode.window.showInformationMessage(`${json.quote}`);

try {
const response = await fetch(apiUrl);
const json = await response.json();
if (response.status === 200) {
vscode.window.showInformationMessage(`${json.quote}`);
} else {
vscode.window.showInformationMessage(`Something went Wrong\nContact Developer`);
}
} catch (error) {
vscode.window.showInformationMessage(`I can't work Offline`);
}

}
export function deactivate() { }

0 comments on commit dc33ed7

Please sign in to comment.