Skip to content

Commit

Permalink
refactor: consistent error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jul 15, 2021
1 parent b67d64b commit 8449e46
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/components/FeedItemMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export default {
body: this.$t('components.tipRecords.TipRecord.claimBodySuccess'),
});
this.resolve();
} catch (e) {
} catch (error) {
await this.$store.dispatch('modals/open', {
name: 'failure',
title: this.$t('components.tipRecords.TipRecord.claimTitle'),
body: this.$t('components.tipRecords.TipRecord.claimBodyFailure'),
});
console.error(error);
}
},
async pinOrUnPinTip() {
Expand Down
5 changes: 2 additions & 3 deletions src/components/SendComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</template>

<script>
import { handleUnknownError } from '../utils';
import MessageInput from './MessageInput.vue';
export default {
Expand Down Expand Up @@ -43,8 +42,8 @@ export default {
{ text: this.comment, tipId: this.tipId, parentId: this.parentId },
);
this.comment = '';
} catch (e) {
if (e.message !== 'Operation rejected by user') handleUnknownError(e);
} catch (error) {
if (error.message !== 'Operation rejected by user') throw error;
} finally {
this.loading = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/TipInputPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default {
this.resolve(true);
} catch (error) {
this.error = true;
throw error;
console.error(error);
} finally {
this.showLoading = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export default {
joinedAtISO() {
try {
return new Date(this.profile.createdAt).toISOString();
} catch (e) {
} catch {
return '';
}
},
Expand All @@ -276,7 +276,7 @@ export default {
month: 'long',
day: 'numeric',
});
} catch (e) {
} catch {
return '';
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const validateTipUrl = (urlAsString) => {
try {
const url = toURL(urlAsString);
return ['http:', 'https:'].includes(url.protocol) && isFQDN(url.hostname);
} catch (e) {
} catch {
return false;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/views/TipsAndComments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
? 'backend/reloadComment' : 'backend/reloadTip', this.id || this.tipId);
} catch (error) {
this.error = true;
throw error;
console.error(error);
} finally {
this.showLoading = false;
}
Expand Down

0 comments on commit 8449e46

Please sign in to comment.