Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Error Handling in javascript
  • Loading branch information
TabishRehmatullah authored Oct 31, 2021
1 parent a884d5a commit 17d73ed
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ErrorHandling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function greet_user(user) {
console.log('Hi ' + user.name + ', how are you?');
}

var user = {
'name': ""
}

try {

if (!user.name) {
throw 'Name is empty';
}

greet_user(user);

} catch (err) {
console.log(err);
console.log('Hi guest user, how are you?');
}

0 comments on commit 17d73ed

Please sign in to comment.