Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

Switch Errors enum to object (#5772)

authored by yoginth.com and committed by

GitHub 8eabd239 f9031093

+86 -84
+2 -2
apps/api/src/routes/cron/guild/syncFollowersStandingToGuild.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import lensPg from "src/utils/lensPg"; 4 4 import syncAddressesToGuild from "src/utils/syncAddressesToGuild"; ··· 26 26 27 27 return ctx.json(data); 28 28 } catch { 29 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 29 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 30 30 } 31 31 }; 32 32
+2 -2
apps/api/src/routes/cron/guild/syncSubscribersToGuild.ts
··· 1 1 import { PERMISSIONS } from "@hey/data/constants"; 2 - import { Errors } from "@hey/data/errors"; 2 + import { ERRORS } from "@hey/data/errors"; 3 3 import type { Context } from "hono"; 4 4 import lensPg from "src/utils/lensPg"; 5 5 import syncAddressesToGuild from "src/utils/syncAddressesToGuild"; ··· 32 32 33 33 return ctx.json(data); 34 34 } catch { 35 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 35 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 36 36 } 37 37 }; 38 38
+2 -2
apps/api/src/routes/cron/removeExpiredSubscribers/index.ts
··· 1 1 import { PERMISSIONS } from "@hey/data/constants"; 2 - import { Errors } from "@hey/data/errors"; 2 + import { ERRORS } from "@hey/data/errors"; 3 3 import type { Context } from "hono"; 4 4 import lensPg from "src/utils/lensPg"; 5 5 import signer from "src/utils/signer"; ··· 41 41 42 42 return ctx.json({ success: true, addresses, hash }); 43 43 } catch { 44 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 44 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 45 45 } 46 46 }; 47 47
+2 -2
apps/api/src/routes/jumper/getStats.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import getDbPostId from "src/utils/getDbPostId"; 4 4 import lensPg from "src/utils/lensPg"; ··· 60 60 comments: Number(result[2].count) 61 61 }); 62 62 } catch { 63 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 63 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 64 64 } 65 65 }; 66 66
+2 -2
apps/api/src/routes/lens/authorization.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 4 4 const authorization = async (ctx: Context) => { ··· 21 21 signingKey: process.env.PRIVATE_KEY 22 22 }); 23 23 } catch { 24 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 24 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 25 25 } 26 26 }; 27 27
+2 -2
apps/api/src/routes/live/createLive.ts
··· 1 1 import { LIVEPEER_KEY } from "@hey/data/constants"; 2 - import { Errors } from "@hey/data/errors"; 2 + import { ERRORS } from "@hey/data/errors"; 3 3 import generateUUID from "@hey/helpers/generateUUID"; 4 4 import type { Context } from "hono"; 5 5 ··· 45 45 } 46 46 }); 47 47 } catch { 48 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 48 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 49 49 } 50 50 }; 51 51
+2 -2
apps/api/src/routes/metadata/getSTS.ts
··· 1 1 import { AssumeRoleCommand, STSClient } from "@aws-sdk/client-sts"; 2 2 import { EVER_API, EVER_BUCKET, EVER_REGION } from "@hey/data/constants"; 3 - import { Errors } from "@hey/data/errors"; 3 + import { ERRORS } from "@hey/data/errors"; 4 4 import type { Context } from "hono"; 5 5 6 6 const params = { ··· 49 49 } 50 50 }); 51 51 } catch { 52 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 52 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 53 53 } 54 54 }; 55 55
+2 -2
apps/api/src/routes/oembed/getOembed.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { CACHE_AGE_1_DAY } from "src/utils/constants"; 4 4 import { generateExtraLongExpiry, getRedis, setRedis } from "src/utils/redis"; ··· 26 26 27 27 return ctx.json({ success: true, data: oembed }); 28 28 } catch { 29 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 29 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 30 30 } 31 31 }; 32 32
+2 -2
apps/api/src/routes/preferences/getPreferences.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import prisma from "src/prisma/client"; 4 4 import { getRedis, setRedis } from "src/utils/redis"; ··· 31 31 32 32 return ctx.json({ success: true, data }); 33 33 } catch { 34 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 34 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 35 35 } 36 36 }; 37 37
+2 -2
apps/api/src/routes/preferences/updatePreferences.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import prisma from "src/prisma/client"; 4 4 import { delRedis } from "src/utils/redis"; ··· 24 24 } 25 25 }); 26 26 } catch { 27 - return ctx.json({ success: false, error: Errors.SomethingWentWrong }, 500); 27 + return ctx.json({ success: false, error: ERRORS.SomethingWentWrong }, 500); 28 28 } 29 29 }; 30 30
+4 -4
apps/api/src/routes/sitemap/accounts/accountSitemap.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { SITEMAP_BATCH_SIZE } from "src/utils/constants"; 4 4 import lensPg from "src/utils/lensPg"; ··· 11 11 const batch = params["batch.xml"].replace(".xml", ""); 12 12 13 13 if (Number.isNaN(Number(group)) || Number.isNaN(Number(batch))) { 14 - return ctx.body(Errors.SomethingWentWrong); 14 + return ctx.body(ERRORS.SomethingWentWrong); 15 15 } 16 16 17 17 if (Number(group) === 0 || Number(batch) === 0) { 18 - return ctx.body(Errors.SomethingWentWrong); 18 + return ctx.body(ERRORS.SomethingWentWrong); 19 19 } 20 20 21 21 try { ··· 71 71 ctx.header("Content-Type", "application/xml"); 72 72 return ctx.body(sitemap.end({ prettyPrint: true })); 73 73 } catch { 74 - return ctx.body(Errors.SomethingWentWrong); 74 + return ctx.body(ERRORS.SomethingWentWrong); 75 75 } 76 76 }; 77 77
+3 -3
apps/api/src/routes/sitemap/accounts/accountsGroupSitemap.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { SITEMAP_BATCH_SIZE } from "src/utils/constants"; 4 4 import lensPg from "src/utils/lensPg"; ··· 10 10 const groupParam = params["group.xml"].replace(".xml", ""); 11 11 12 12 if (Number.isNaN(Number(groupParam)) || Number(groupParam) === 0) { 13 - return ctx.body(Errors.SomethingWentWrong); 13 + return ctx.body(ERRORS.SomethingWentWrong); 14 14 } 15 15 16 16 const group = Number(groupParam); ··· 59 59 ctx.header("Content-Type", "application/xml"); 60 60 return ctx.body(sitemapIndex.end({ prettyPrint: true })); 61 61 } catch { 62 - return ctx.body(Errors.SomethingWentWrong); 62 + return ctx.body(ERRORS.SomethingWentWrong); 63 63 } 64 64 }; 65 65
+2 -2
apps/api/src/routes/sitemap/accounts/accountsSitemapIndex.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { SITEMAP_BATCH_SIZE } from "src/utils/constants"; 4 4 import lensPg from "src/utils/lensPg"; ··· 47 47 ctx.header("Content-Type", "application/xml"); 48 48 return ctx.body(sitemapIndex.end({ prettyPrint: true })); 49 49 } catch { 50 - return ctx.body(Errors.SomethingWentWrong); 50 + return ctx.body(ERRORS.SomethingWentWrong); 51 51 } 52 52 }; 53 53
+2 -2
apps/api/src/routes/sitemap/pagesSitemap.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { create } from "xmlbuilder2"; 4 4 ··· 31 31 ctx.header("Content-Type", "application/xml"); 32 32 return ctx.body(sitemap.end({ prettyPrint: true })); 33 33 } catch { 34 - return ctx.body(Errors.SomethingWentWrong); 34 + return ctx.body(ERRORS.SomethingWentWrong); 35 35 } 36 36 }; 37 37
+2 -2
apps/api/src/routes/sitemap/sitemapIndex.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import type { Context } from "hono"; 3 3 import { create } from "xmlbuilder2"; 4 4 ··· 28 28 ctx.header("Content-Type", "application/xml"); 29 29 return ctx.body(sitemapIndex.end({ prettyPrint: true })); 30 30 } catch { 31 - return ctx.body(Errors.SomethingWentWrong); 31 + return ctx.body(ERRORS.SomethingWentWrong); 32 32 } 33 33 }; 34 34
+2 -2
apps/web/src/components/Composer/NewPublication.tsx
··· 28 28 usePostVideoStore 29 29 } from "@/store/non-persisted/post/usePostVideoStore"; 30 30 import { useAccountStore } from "@/store/persisted/useAccountStore"; 31 - import { Errors } from "@hey/data/errors"; 31 + import { ERRORS } from "@hey/data/errors"; 32 32 import getAccount from "@hey/helpers/getAccount"; 33 33 import type { PostFragment } from "@hey/indexer"; 34 34 import type { IGif } from "@hey/types/giphy"; ··· 169 169 170 170 const handleCreatePost = async () => { 171 171 if (!currentAccount) { 172 - return toast.error(Errors.SignWallet); 172 + return toast.error(ERRORS.SignWallet); 173 173 } 174 174 175 175 try {
+2 -2
apps/web/src/components/Group/Settings/Personalize/Form.tsx
··· 14 14 import uploadMetadata from "@/helpers/uploadMetadata"; 15 15 import useTransactionLifecycle from "@/hooks/useTransactionLifecycle"; 16 16 import { useAccountStore } from "@/store/persisted/useAccountStore"; 17 - import { Errors } from "@hey/data/errors"; 17 + import { ERRORS } from "@hey/data/errors"; 18 18 import { Regex } from "@hey/data/regex"; 19 19 import { type GroupFragment, useSetGroupMetadataMutation } from "@hey/indexer"; 20 20 import type { ApolloClientError } from "@hey/types/errors"; ··· 89 89 coverUrl: string | undefined 90 90 ) => { 91 91 if (!currentAccount) { 92 - return toast.error(Errors.SignWallet); 92 + return toast.error(ERRORS.SignWallet); 93 93 } 94 94 95 95 setIsSubmitting(true);
+2 -2
apps/web/src/components/Post/Actions/Like.tsx
··· 5 5 import type { ApolloCache } from "@apollo/client"; 6 6 import { HeartIcon } from "@heroicons/react/24/outline"; 7 7 import { HeartIcon as HeartIconSolid } from "@heroicons/react/24/solid"; 8 - import { Errors } from "@hey/data/errors"; 8 + import { ERRORS } from "@hey/data/errors"; 9 9 import { 10 10 type PostFragment, 11 11 PostReactionType, ··· 75 75 76 76 const handleCreateLike = async () => { 77 77 if (!currentAccount) { 78 - return toast.error(Errors.SignWallet); 78 + return toast.error(ERRORS.SignWallet); 79 79 } 80 80 81 81 toggleReact();
+2 -2
apps/web/src/components/Post/Actions/Share/Quote.tsx
··· 4 4 import { useAccountStore } from "@/store/persisted/useAccountStore"; 5 5 import { MenuItem } from "@headlessui/react"; 6 6 import { ChatBubbleBottomCenterTextIcon } from "@heroicons/react/24/outline"; 7 - import { Errors } from "@hey/data/errors"; 7 + import { ERRORS } from "@hey/data/errors"; 8 8 import type { PostFragment } from "@hey/indexer"; 9 9 import { toast } from "sonner"; 10 10 ··· 28 28 } 29 29 onClick={() => { 30 30 if (!currentAccount) { 31 - return toast.error(Errors.SignWallet); 31 + return toast.error(ERRORS.SignWallet); 32 32 } 33 33 setQuotedPost(post); 34 34 setShowNewPostModal(true);
+2 -2
apps/web/src/components/Post/Actions/Share/Repost.tsx
··· 5 5 import { useApolloClient } from "@apollo/client"; 6 6 import { MenuItem } from "@headlessui/react"; 7 7 import { ArrowsRightLeftIcon } from "@heroicons/react/24/outline"; 8 - import { Errors } from "@hey/data/errors"; 8 + import { ERRORS } from "@hey/data/errors"; 9 9 import { type PostFragment, useRepostMutation } from "@hey/indexer"; 10 10 import type { ApolloClientError } from "@hey/types/errors"; 11 11 import { useCounter } from "@uidotdev/usehooks"; ··· 82 82 83 83 const handleCreateRepost = async () => { 84 84 if (!currentAccount) { 85 - return toast.error(Errors.SignWallet); 85 + return toast.error(ERRORS.SignWallet); 86 86 } 87 87 88 88 setIsSubmitting(true);
+2 -2
apps/web/src/components/Post/Actions/Share/UndoRepost.tsx
··· 5 5 import { useApolloClient } from "@apollo/client"; 6 6 import { MenuItem } from "@headlessui/react"; 7 7 import { ArrowsRightLeftIcon } from "@heroicons/react/24/outline"; 8 - import { Errors } from "@hey/data/errors"; 8 + import { ERRORS } from "@hey/data/errors"; 9 9 import { isRepost } from "@hey/helpers/postHelpers"; 10 10 import { type AnyPostFragment, useDeletePostMutation } from "@hey/indexer"; 11 11 import type { Dispatch, SetStateAction } from "react"; ··· 67 67 68 68 const handleUndoRepost = async () => { 69 69 if (!currentAccount) { 70 - return toast.error(Errors.SignWallet); 70 + return toast.error(ERRORS.SignWallet); 71 71 } 72 72 73 73 setIsSubmitting(true);
+2 -2
apps/web/src/components/Settings/Developer/Tokens.tsx
··· 4 4 import useCopyToClipboard from "@/hooks/useCopyToClipboard"; 5 5 import useHandleWrongNetwork from "@/hooks/useHandleWrongNetwork"; 6 6 import { hydrateAuthTokens } from "@/store/persisted/useAuthStore"; 7 - import { Errors } from "@hey/data/errors"; 7 + import { ERRORS } from "@hey/data/errors"; 8 8 import { useAuthenticateMutation, useChallengeMutation } from "@hey/indexer"; 9 9 import type { ApolloClientError } from "@hey/types/errors"; 10 10 import { useState } from "react"; ··· 51 51 }); 52 52 53 53 if (!challenge?.data?.challenge?.text) { 54 - return toast.error(Errors.SomethingWentWrong); 54 + return toast.error(ERRORS.SomethingWentWrong); 55 55 } 56 56 57 57 // Get signature
+2 -2
apps/web/src/components/Settings/Manager/AccountManager/AddAccountManager.tsx
··· 5 5 import useWaitForTransactionToComplete from "@/hooks/useWaitForTransactionToComplete"; 6 6 import { useAccountStore } from "@/store/persisted/useAccountStore"; 7 7 import { ADDRESS_PLACEHOLDER } from "@hey/data/constants"; 8 - import { Errors } from "@hey/data/errors"; 8 + import { ERRORS } from "@hey/data/errors"; 9 9 import { useAddAccountManagerMutation } from "@hey/indexer"; 10 10 import type { ApolloClientError } from "@hey/types/errors"; 11 11 import type { Dispatch, SetStateAction } from "react"; ··· 53 53 54 54 const handleAddManager = async () => { 55 55 if (!currentAccount) { 56 - return toast.error(Errors.SignWallet); 56 + return toast.error(ERRORS.SignWallet); 57 57 } 58 58 59 59 setIsSubmitting(true);
+2 -2
apps/web/src/components/Settings/Manager/AccountManager/Managers/List.tsx
··· 7 7 import { useAccountStore } from "@/store/persisted/useAccountStore"; 8 8 import { useApolloClient } from "@apollo/client"; 9 9 import { UserCircleIcon } from "@heroicons/react/24/outline"; 10 - import { Errors } from "@hey/data/errors"; 10 + import { ERRORS } from "@hey/data/errors"; 11 11 import { 12 12 type AccountManagerFragment, 13 13 type AccountManagersRequest, ··· 65 65 66 66 const handleRemoveManager = async (manager: AccountManagerFragment) => { 67 67 if (!currentAccount) { 68 - return toast.error(Errors.SignWallet); 68 + return toast.error(ERRORS.SignWallet); 69 69 } 70 70 71 71 setRemovingManager(manager);
+2 -2
apps/web/src/components/Settings/Personalize/Form.tsx
··· 18 18 import useWaitForTransactionToComplete from "@/hooks/useWaitForTransactionToComplete"; 19 19 import { useAccountStore } from "@/store/persisted/useAccountStore"; 20 20 import { BANNER_IDS } from "@hey/data/constants"; 21 - import { Errors } from "@hey/data/errors"; 21 + import { ERRORS } from "@hey/data/errors"; 22 22 import { Regex } from "@hey/data/regex"; 23 23 import { useMeLazyQuery, useSetAccountMetadataMutation } from "@hey/indexer"; 24 24 import type { ApolloClientError } from "@hey/types/errors"; ··· 122 122 coverUrl: string | undefined 123 123 ) => { 124 124 if (!currentAccount) { 125 - return toast.error(Errors.SignWallet); 125 + return toast.error(ERRORS.SignWallet); 126 126 } 127 127 128 128 setIsSubmitting(true);
+2 -2
apps/web/src/components/Shared/Account/SwitchAccounts.tsx
··· 4 4 import { useAccountStore } from "@/store/persisted/useAccountStore"; 5 5 import { signIn, signOut } from "@/store/persisted/useAuthStore"; 6 6 import { CheckCircleIcon } from "@heroicons/react/24/solid"; 7 - import { Errors } from "@hey/data/errors"; 7 + import { ERRORS } from "@hey/data/errors"; 8 8 import { 9 9 ManagedAccountsVisibility, 10 10 useAccountsAvailableQuery, ··· 72 72 return location.reload(); 73 73 } 74 74 75 - return onError({ message: Errors.SomethingWentWrong }); 75 + return onError({ message: ERRORS.SomethingWentWrong }); 76 76 } catch { 77 77 onError(); 78 78 }
+2 -2
apps/web/src/components/Shared/Alert/BlockOrUnblockAccount.tsx
··· 4 4 import { useBlockAlertStore } from "@/store/non-persisted/alert/useBlockAlertStore"; 5 5 import { useAccountStore } from "@/store/persisted/useAccountStore"; 6 6 import { useApolloClient } from "@apollo/client"; 7 - import { Errors } from "@hey/data/errors"; 7 + import { ERRORS } from "@hey/data/errors"; 8 8 import getAccount from "@hey/helpers/getAccount"; 9 9 import { useBlockMutation, useUnblockMutation } from "@hey/indexer"; 10 10 import type { ApolloClientError } from "@hey/types/errors"; ··· 85 85 86 86 const blockOrUnblock = async () => { 87 87 if (!currentAccount) { 88 - return toast.error(Errors.SignWallet); 88 + return toast.error(ERRORS.SignWallet); 89 89 } 90 90 91 91 setIsSubmitting(true);
+2 -2
apps/web/src/components/Shared/Alert/MuteOrUnmuteAccount.tsx
··· 3 3 import { useMuteAlertStore } from "@/store/non-persisted/alert/useMuteAlertStore"; 4 4 import { useAccountStore } from "@/store/persisted/useAccountStore"; 5 5 import { useApolloClient } from "@apollo/client"; 6 - import { Errors } from "@hey/data/errors"; 6 + import { ERRORS } from "@hey/data/errors"; 7 7 import getAccount from "@hey/helpers/getAccount"; 8 8 import { useMuteMutation, useUnmuteMutation } from "@hey/indexer"; 9 9 import type { ApolloClientError } from "@hey/types/errors"; ··· 60 60 61 61 const muteOrUnmute = async () => { 62 62 if (!currentAccount) { 63 - return toast.error(Errors.SignWallet); 63 + return toast.error(ERRORS.SignWallet); 64 64 } 65 65 66 66 setIsSubmitting(true);
+4 -4
apps/web/src/components/Shared/Auth/Login.tsx
··· 4 4 import { EXPANSION_EASE } from "@/variants"; 5 5 import { KeyIcon } from "@heroicons/react/24/outline"; 6 6 import { HEY_APP, IS_MAINNET } from "@hey/data/constants"; 7 - import { Errors } from "@hey/data/errors"; 7 + import { ERRORS } from "@hey/data/errors"; 8 8 import { 9 9 type ChallengeRequest, 10 10 ManagedAccountsVisibility, ··· 97 97 }); 98 98 99 99 if (!challenge?.data?.challenge?.text) { 100 - return toast.error(Errors.SomethingWentWrong); 100 + return toast.error(ERRORS.SomethingWentWrong); 101 101 } 102 102 103 103 // Get signature ··· 117 117 return location.reload(); 118 118 } 119 119 120 - return onError({ message: Errors.SomethingWentWrong }); 120 + return onError({ message: ERRORS.SomethingWentWrong }); 121 121 } catch { 122 122 onError(); 123 123 } ··· 129 129 {errorChallenge || errorAuthenticate ? ( 130 130 <ErrorMessage 131 131 className="text-red-500" 132 - title={Errors.SomethingWentWrong} 132 + title={ERRORS.SomethingWentWrong} 133 133 error={errorChallenge || errorAuthenticate} 134 134 /> 135 135 ) : null}
+3 -3
apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx
··· 9 9 FaceSmileIcon 10 10 } from "@heroicons/react/24/outline"; 11 11 import { HEY_APP, IS_MAINNET } from "@hey/data/constants"; 12 - import { Errors } from "@hey/data/errors"; 12 + import { ERRORS } from "@hey/data/errors"; 13 13 import { Regex } from "@hey/data/regex"; 14 14 import { 15 15 useAccountQuery, ··· 100 100 }); 101 101 102 102 if (!challenge?.data?.challenge?.text) { 103 - return toast.error(Errors.SomethingWentWrong); 103 + return toast.error(ERRORS.SomethingWentWrong); 104 104 } 105 105 106 106 // Get signature ··· 140 140 }); 141 141 } 142 142 143 - return onError({ message: Errors.SomethingWentWrong }); 143 + return onError({ message: ERRORS.SomethingWentWrong }); 144 144 } catch { 145 145 onError(); 146 146 } finally {
+3 -3
apps/web/src/components/Shared/Auth/Signup/Success.tsx
··· 2 2 import errorToast from "@/helpers/errorToast"; 3 3 import { signIn } from "@/store/persisted/useAuthStore"; 4 4 import { STATIC_IMAGES_URL } from "@hey/data/constants"; 5 - import { Errors } from "@hey/data/errors"; 5 + import { ERRORS } from "@hey/data/errors"; 6 6 import { useSwitchAccountMutation } from "@hey/indexer"; 7 7 import type { ApolloClientError } from "@hey/types/errors"; 8 8 import { useEffect } from "react"; ··· 31 31 return location.reload(); 32 32 } 33 33 34 - return onError({ message: Errors.SomethingWentWrong }); 34 + return onError({ message: ERRORS.SomethingWentWrong }); 35 35 } catch { 36 - onError({ message: Errors.SomethingWentWrong }); 36 + onError({ message: ERRORS.SomethingWentWrong }); 37 37 } 38 38 }; 39 39
+3 -3
apps/web/src/components/Shared/EmojiPicker/List.tsx
··· 3 3 import stopEventPropagation from "@/helpers/stopEventPropagation"; 4 4 import useEmojis from "@/hooks/prosekit/useEmojis"; 5 5 import { MagnifyingGlassIcon, XMarkIcon } from "@heroicons/react/24/outline"; 6 - import { Errors } from "@hey/data/errors"; 6 + import { ERRORS } from "@hey/data/errors"; 7 7 import type { Emoji } from "@hey/types/misc"; 8 8 import type { ChangeEvent, MouseEvent } from "react"; 9 9 import { useEffect, useRef, useState } from "react"; ··· 42 42 className="m-5" 43 43 error={{ 44 44 message: "Error while loading emojis", 45 - name: Errors.SomethingWentWrong 45 + name: ERRORS.SomethingWentWrong 46 46 }} 47 - title={Errors.SomethingWentWrong} 47 + title={ERRORS.SomethingWentWrong} 48 48 /> 49 49 ); 50 50 }
+2 -2
apps/web/src/helpers/errorToast.ts
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import { toast } from "sonner"; 3 3 4 4 const FORBIDDEN_ERROR_PREFIX = ··· 38 38 return; 39 39 } 40 40 41 - toast.error(message || Errors.SomethingWentWrong, { id: "error" }); 41 + toast.error(message || ERRORS.SomethingWentWrong, { id: "error" }); 42 42 }; 43 43 44 44 export default errorToast;
+2 -2
apps/web/src/helpers/uploadMetadata.ts
··· 1 1 import { CHAIN } from "@hey/data/constants"; 2 - import { Errors } from "@hey/data/errors"; 2 + import { ERRORS } from "@hey/data/errors"; 3 3 import { immutable } from "@lens-chain/storage-client"; 4 4 import { storageClient } from "./storageClient"; 5 5 ··· 17 17 18 18 return uri; 19 19 } catch { 20 - throw new Error(Errors.SomethingWentWrong); 20 + throw new Error(ERRORS.SomethingWentWrong); 21 21 } 22 22 }; 23 23
+2 -2
apps/web/src/hooks/useImageCropUpload.tsx
··· 6 6 STATIC_IMAGES_URL, 7 7 type TRANSFORMS 8 8 } from "@hey/data/constants"; 9 - import { Errors } from "@hey/data/errors"; 9 + import { ERRORS } from "@hey/data/errors"; 10 10 import imageKit from "@hey/helpers/imageKit"; 11 11 import sanitizeDStorageUrl from "@hey/helpers/sanitizeDStorageUrl"; 12 12 import type { ApolloClientError } from "@hey/types/errors"; ··· 48 48 const croppedImage = await getCroppedImg(pictureSrc, area); 49 49 50 50 if (!croppedImage) { 51 - return toast.error(Errors.SomethingWentWrong); 51 + return toast.error(ERRORS.SomethingWentWrong); 52 52 } 53 53 54 54 const decentralizedUrl = await uploadCroppedImage(croppedImage);
+2 -2
apps/web/src/hooks/useTransactionLifecycle.tsx
··· 1 - import { Errors } from "@hey/data/errors"; 1 + import { ERRORS } from "@hey/data/errors"; 2 2 import getTransactionData from "@hey/helpers/getTransactionData"; 3 3 import type { ApolloClientError } from "@hey/types/errors"; 4 4 import { sendEip712Transaction, sendTransaction } from "viem/zksync"; ··· 58 58 case "TransactionWillFail": 59 59 return onError({ message: transactionData.reason }); 60 60 default: 61 - throw onError({ message: Errors.SomethingWentWrong }); 61 + throw onError({ message: ERRORS.SomethingWentWrong }); 62 62 } 63 63 } catch (error) { 64 64 return onError(error);
+6 -4
packages/data/errors.ts
··· 1 - export enum Errors { 2 - SignWallet = "Please sign in your wallet.", 3 - SomethingWentWrong = "Something went wrong!" 4 - } 1 + export const ERRORS = { 2 + SignWallet: "Please sign in your wallet.", 3 + SomethingWentWrong: "Something went wrong!" 4 + } as const; 5 + 6 + export type ErrorMessage = (typeof ERRORS)[keyof typeof ERRORS];