Skip to content

Commit

Permalink
Better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
szczygiel-m committed Sep 13, 2023
1 parent eb7684e commit 0eaa1b3
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ export function useConstraints(): UseConstraints {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.constraints.topic.created.failure',
{
topicName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -100,15 +103,18 @@ export function useConstraints(): UseConstraints {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.constraints.topic.deleted.failure',
{
topicName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
}
Expand All @@ -135,15 +141,18 @@ export function useConstraints(): UseConstraints {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.constraints.subscription.created.failure',
{
subscriptionFqn,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down Expand Up @@ -171,15 +180,18 @@ export function useConstraints(): UseConstraints {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.constraints.subscription.deleted.failure',
{
subscriptionFqn,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ export function useConsumerGroups(
text: '',
type: 'success',
});
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.subscriptionOffsets.move.failure',
{
subscriptionName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
}
Expand Down
14 changes: 10 additions & 4 deletions hermes-console-vue/src/composables/groups/use-groups/useGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ export function useGroups(): UseGroups {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.group.delete.failure', {
groupId,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -107,12 +110,15 @@ export function useGroups(): UseGroups {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.group.create.failure', {
groupId,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ export function useInconsistentTopics(): UseInconsistentTopics {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.inconsistentTopic.delete.failure',
{
topic,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ export function useReadiness(): UseReadiness {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.readiness.switch.failure', {
datacenter,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import {
createSubscription as doCreateSubscription,
searchOwners,
Expand Down Expand Up @@ -90,8 +89,9 @@ export function useCreateSubscription(topic: string): UseCreateSubscription {
});
return true;
} catch (e: any) {
const text =
e instanceof AxiosError ? e.message : 'Unknown error occurred';
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationsStore.dispatchNotification({
title: useGlobalI18n().t('notifications.subscription.create.failure'),
text,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import {
editSubscription as doEditSubscription,
fetchOwner,
Expand Down Expand Up @@ -96,8 +95,9 @@ export function useEditSubscription(
});
return true;
} catch (e: any) {
const text =
e instanceof AxiosError ? e.message : 'Unknown error occurred';
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationsStore.dispatchNotification({
title: useGlobalI18n().t('notifications.subscription.edit.failure'),
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,15 @@ export function useSubscription(
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.subscription.delete.failure', {
subscriptionName,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -175,12 +178,15 @@ export function useSubscription(
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.subscription.suspend.failure', {
subscriptionName,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -197,15 +203,18 @@ export function useSubscription(
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.subscription.activate.failure',
{
subscriptionName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -228,15 +237,18 @@ export function useSubscription(
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.subscription.retransmit.failure',
{
subscriptionName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand All @@ -261,15 +273,18 @@ export function useSubscription(
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.subscription.skipAllMessages.failure',
{
subscriptionName,
},
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ export function useOfflineRetransmission(): UseOfflineRetransmission {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
await notificationsStore.dispatchNotification({
title: useGlobalI18n().t(
'notifications.offlineRetransmission.create.failure',
{ sourceTopic: task.sourceTopic, targetTopic: task.targetTopic },
),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ export function useTopic(topicName: string): UseTopic {
type: 'success',
});
return true;
} catch (e) {
} catch (e: any) {
const text = e.response?.data?.message
? e.response.data.message
: 'Unknown error occurred';
notificationStore.dispatchNotification({
title: useGlobalI18n().t('notifications.topic.delete.failure', {
topicName,
}),
text: (e as Error).message,
text,
type: 'error',
});
return false;
Expand Down

0 comments on commit 0eaa1b3

Please sign in to comment.