Update error handling

This commit is contained in:
delivan 2022-12-20 23:09:26 +09:00
parent fdfbb02f98
commit 25d130073c
3 changed files with 8 additions and 11 deletions

View File

@ -29,7 +29,7 @@ export const queryRegisteredTwitterId = async (
Buffer.from(JSON.stringify(msg)).toString("base64"), Buffer.from(JSON.stringify(msg)).toString("base64"),
), ),
{}, {},
true, { isErrorIgnore: true },
); );
}; };
@ -61,6 +61,6 @@ export const queryOwnerOfTwitterName = async (
Buffer.from(JSON.stringify(msg)).toString("base64"), Buffer.from(JSON.stringify(msg)).toString("base64"),
), ),
{}, {},
true, { isErrorIgnore: true },
); );
}; };

View File

@ -5,15 +5,10 @@
import * as Sentry from "@sentry/nextjs"; import * as Sentry from "@sentry/nextjs";
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const IS_ENABLE_USER_TRACKING =
process.env.NEXT_PUBLIC_IS_ENABLE_USER_TRACKING ||
process.env.NEXT_IS_ENABLE_USER_TRACKING;
Sentry.init({ Sentry.init({
enabled: IS_ENABLE_USER_TRACKING === "true", enabled: !!SENTRY_DSN,
dsn: dsn: SENTRY_DSN,
SENTRY_DSN ||
"https://78c91641e90f4f7cad28f50aaec9fb95@o4504343701946368.ingest.sentry.io/4504343708827648",
// Adjust this value in production, or use tracesSampler for greater control // Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
// ... // ...

View File

@ -5,11 +5,13 @@ import { WALLET_INSTALL_URL } from "../constants/wallet";
export function request<TResponse>( export function request<TResponse>(
url: string, url: string,
config: RequestInit = {}, config: RequestInit = {},
isIgnore?: boolean, customConfig?: {
isErrorIgnore?: boolean;
},
): Promise<TResponse> { ): Promise<TResponse> {
return fetch(url, config) return fetch(url, config)
.then((response) => { .then((response) => {
if (!response.ok && !isIgnore) { if (!response.ok && !customConfig?.isErrorIgnore) {
throw new Error( throw new Error(
`This is an HTTP error: The status is ${response.status} ${response.statusText}`, `This is an HTTP error: The status is ${response.status} ${response.statusText}`,
); );