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 7, 2021
1 parent 22d8324 commit d77ddfd
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/ListOfTipsAndComments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
this.error = false;
} catch (error) {
this.error = true;
throw error;
console.error(error);
} finally {
this.showLoading = false;
}
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/TipInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default {
this.hideModal();
} 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 @@ -272,7 +272,7 @@ export default {
joinedAtISO() {
try {
return new Date(this.profile.createdAt).toISOString();
} catch (e) {
} catch {
return '';
}
},
Expand All @@ -284,7 +284,7 @@ export default {
month: 'long',
day: 'numeric',
});
} catch (e) {
} catch {
return '';
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/tipRecords/TipRecord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ export default {
title: this.$t('components.tipRecords.TipRecord.claimTitle'),
body: this.$t('components.tipRecords.TipRecord.claimBodySuccess'),
});
} catch (e) {
} catch (error) {
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
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 d77ddfd

Please sign in to comment.