mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix: improve error handling by replacing catch blocks with empty catch statements across multiple components
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-restricted-types
|
||||
type GenericFunction = Function;
|
||||
|
||||
export default GenericFunction;
|
||||
|
||||
@@ -57,7 +57,9 @@ const CheckBoxList: FunctionComponent<CategoryProps> = (
|
||||
)}
|
||||
onChange={(changedValue: boolean) => {
|
||||
if (changedValue) {
|
||||
props.onChecked && props.onChecked(option.value);
|
||||
if (props.onChecked) {
|
||||
props.onChecked(option.value);
|
||||
}
|
||||
|
||||
// add the option.value to the currentValues array
|
||||
const newValues: Array<CategoryCheckboxValue> = [
|
||||
@@ -72,7 +74,9 @@ const CheckBoxList: FunctionComponent<CategoryProps> = (
|
||||
setCurrentValues(newValues);
|
||||
props.onChange(newValues);
|
||||
} else {
|
||||
props.onUnchecked && props.onUnchecked(option.value);
|
||||
if (props.onUnchecked) {
|
||||
props.onUnchecked(option.value);
|
||||
}
|
||||
|
||||
// remove the option.value from the currentValues array
|
||||
|
||||
|
||||
@@ -101,8 +101,12 @@ const CodeEditor: FunctionComponent<ComponentProps> = (
|
||||
<div
|
||||
data-testid={props.dataTestId}
|
||||
onClick={() => {
|
||||
props.onClick && props.onClick();
|
||||
props.onFocus && props.onFocus();
|
||||
if (props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
if (props.onFocus) {
|
||||
props.onFocus();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{helpText && (
|
||||
@@ -122,8 +126,12 @@ const CodeEditor: FunctionComponent<ComponentProps> = (
|
||||
}
|
||||
|
||||
setValue(code);
|
||||
props.onBlur && props.onBlur();
|
||||
props.onChange && props.onChange(code);
|
||||
if (props.onBlur) {
|
||||
props.onBlur();
|
||||
}
|
||||
if (props.onChange) {
|
||||
props.onChange(code);
|
||||
}
|
||||
}}
|
||||
defaultValue={value || placeholder || ""}
|
||||
className={className}
|
||||
|
||||
@@ -7,7 +7,7 @@ import React, {
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
export interface RadioOption extends DropdownOption {}
|
||||
export type RadioOption = DropdownOption;
|
||||
|
||||
export type RadioValue = DropdownValue;
|
||||
|
||||
@@ -50,9 +50,15 @@ const Radio: FunctionComponent<ComponentProps> = (
|
||||
checked={value === option.value}
|
||||
onClick={() => {
|
||||
setValue(option.value);
|
||||
props.onChange && props.onChange(option.value);
|
||||
props.onBlur && props.onBlur();
|
||||
props.onFocus && props.onFocus();
|
||||
if (props.onChange) {
|
||||
props.onChange(option.value);
|
||||
}
|
||||
if (props.onBlur) {
|
||||
props.onBlur();
|
||||
}
|
||||
if (props.onFocus) {
|
||||
props.onFocus();
|
||||
}
|
||||
}}
|
||||
name={groupName}
|
||||
type="radio"
|
||||
|
||||
@@ -21,8 +21,8 @@ const Tabs: FunctionComponent<ComponentProps> = (
|
||||
}, [props.tabs]);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentTab) {
|
||||
props.onTabChange && props.onTabChange(currentTab);
|
||||
if (currentTab && props.onTabChange) {
|
||||
props.onTabChange(currentTab);
|
||||
}
|
||||
}, [currentTab]);
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ const TextArea: FunctionComponent<ComponentProps> = (
|
||||
|
||||
const handleChange: HandleChangeFunction = (content: string): void => {
|
||||
setText(content);
|
||||
props.onChange && props.onChange(content);
|
||||
if (props.onChange) {
|
||||
props.onChange(content);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -24,8 +24,8 @@ import AggregateBy from "../../../Types/BaseDatabase/AggregateBy";
|
||||
import AggregatedResult from "../../../Types/BaseDatabase/AggregatedResult";
|
||||
import Query from "../../../Types/BaseDatabase/Query";
|
||||
|
||||
export interface ListResult<TAnalyticsBaseModel extends AnalyticsBaseModel>
|
||||
extends BaseListResult<TAnalyticsBaseModel> {}
|
||||
export type ListResult<TAnalyticsBaseModel extends AnalyticsBaseModel> =
|
||||
BaseListResult<TAnalyticsBaseModel>;
|
||||
|
||||
export default class ModelAPI {
|
||||
public static async create<
|
||||
|
||||
@@ -28,8 +28,8 @@ export class ModelAPIHttpResponse<
|
||||
public miscData?: JSONObject | undefined;
|
||||
}
|
||||
|
||||
export interface ListResult<TBaseModel extends BaseModel>
|
||||
extends BaseListResult<TBaseModel> {}
|
||||
export type ListResult<TBaseModel extends BaseModel> =
|
||||
BaseListResult<TBaseModel>;
|
||||
|
||||
export interface RequestOptions extends BaseRequestOptions {
|
||||
isMultiTenantRequest?: boolean | undefined;
|
||||
|
||||
@@ -555,7 +555,7 @@ return {
|
||||
...errors,
|
||||
requestBody: "",
|
||||
});
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setErrors({
|
||||
...errors,
|
||||
requestBody: "Invalid JSON",
|
||||
|
||||
@@ -318,7 +318,7 @@ const DashboardHeader: FunctionComponent<ComponentProps> = (
|
||||
|
||||
setCurrentOnCallPolicies(currentOnCallPolicies);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setOnCallDutyPolicyFetchError(
|
||||
"Something isnt right, we are unable to fetch on-call policies that you are on duty for. Reload the page to try again.",
|
||||
);
|
||||
|
||||
@@ -17,7 +17,9 @@ const Logo: FunctionComponent<ComponentProps> = (
|
||||
<Image
|
||||
className="block h-8 w-auto"
|
||||
onClick={() => {
|
||||
props.onClick && props.onClick();
|
||||
if (props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
}}
|
||||
imageUrl={Route.fromString(`${OneUptimeLogo}`)}
|
||||
alt={"OneUptime"}
|
||||
|
||||
@@ -169,7 +169,7 @@ const MonitorMetricsElement: FunctionComponent<ComponentProps> = (
|
||||
if (typeof attributes === "string") {
|
||||
try {
|
||||
attributes = JSONFunctions.parseJSONObject(attributes);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return {
|
||||
title:
|
||||
MonitorMetricTypeUtil.getTitleByMonitorMetricType(
|
||||
@@ -231,7 +231,7 @@ const MonitorMetricsElement: FunctionComponent<ComponentProps> = (
|
||||
if (typeof attributes === "string") {
|
||||
try {
|
||||
attributes = JSONFunctions.parseJSONObject(attributes);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return {
|
||||
title:
|
||||
MonitorMetricTypeUtil.getTitleByMonitorMetricType(
|
||||
|
||||
@@ -48,7 +48,7 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
|
||||
);
|
||||
setUnresolvedIncidentStates(unresolvedIncidentStates);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// maybe show an error message
|
||||
}
|
||||
};
|
||||
@@ -60,7 +60,7 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
|
||||
await AlertStateUtil.getUnresolvedAlertStates(props.project?.id);
|
||||
setUnresolvedAlertStates(unresolvedAlertStates);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// maybe show an error message
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ import React, {
|
||||
} from "react";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
|
||||
export interface ComponentProps extends PageComponentProps {}
|
||||
export type ComponentProps = PageComponentProps;
|
||||
|
||||
const Settings: FunctionComponent<ComponentProps> = (
|
||||
_props: ComponentProps,
|
||||
|
||||
@@ -39,7 +39,7 @@ import BillingPaymentMethod from "Common/Models/DatabaseModels/BillingPaymentMet
|
||||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
||||
import ListResult from "Common/Types/BaseDatabase/ListResult";
|
||||
|
||||
export interface ComponentProps extends PageComponentProps {}
|
||||
export type ComponentProps = PageComponentProps;
|
||||
|
||||
const Settings: FunctionComponent<ComponentProps> = (
|
||||
_props: ComponentProps,
|
||||
|
||||
@@ -212,7 +212,7 @@ const MonitorSecrets: FunctionComponent<
|
||||
});
|
||||
|
||||
setCurrentlyEditingItem(null);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import TelemetryService from "Common/Models/DatabaseModels/TelemetryService";
|
||||
import TelemetryUsageBilling from "Common/Models/DatabaseModels/TelemetryUsageBilling";
|
||||
import React, { Fragment, FunctionComponent, ReactElement } from "react";
|
||||
|
||||
export interface ComponentProps extends PageComponentProps {}
|
||||
export type ComponentProps = PageComponentProps;
|
||||
|
||||
const Settings: FunctionComponent<ComponentProps> = (
|
||||
_props: ComponentProps,
|
||||
|
||||
@@ -22,7 +22,7 @@ test.describe("Account Registration", () => {
|
||||
try {
|
||||
// reload page if it fails to load
|
||||
dashboardPageResult = await page.reload();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// reload page if it fails to load
|
||||
dashboardPageResult = await page.goto(
|
||||
URL.fromString(BASE_URL.toString()).addRoute("/dashboard").toString(),
|
||||
@@ -40,7 +40,7 @@ test.describe("Account Registration", () => {
|
||||
try {
|
||||
// reload page if it fails to load
|
||||
pageResult = await page.reload();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// reload page if it fails to load
|
||||
pageResult = await page.goto(
|
||||
URL.fromString(BASE_URL.toString())
|
||||
|
||||
@@ -99,7 +99,7 @@ router.post(
|
||||
// check if its parseable to json
|
||||
try {
|
||||
logItem = JSON.parse(logItem);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export class ModelAPIHttpResponse<
|
||||
public miscData?: JSONObject | undefined;
|
||||
}
|
||||
|
||||
export interface ListResult<TBaseModel extends BaseModel>
|
||||
extends BaseListResult<TBaseModel> {}
|
||||
export type ListResult<TBaseModel extends BaseModel> =
|
||||
BaseListResult<TBaseModel>;
|
||||
|
||||
export default interface RequestOptions {
|
||||
requestHeaders?: Dictionary<string> | undefined;
|
||||
|
||||
@@ -130,7 +130,7 @@ export default class SSLMonitor {
|
||||
port,
|
||||
rejectUnauthorized: true,
|
||||
});
|
||||
} catch (err) {
|
||||
} catch {
|
||||
try {
|
||||
certificate = await this.getCertificate({
|
||||
host,
|
||||
|
||||
@@ -107,7 +107,7 @@ settings:
|
||||
try {
|
||||
execSync(generateCommand, { stdio: "inherit" });
|
||||
Logger.info("✅ Terraform provider generated successfully");
|
||||
} catch (error: any) {
|
||||
} catch {
|
||||
Logger.error("❌ Provider generation failed with tfplugingen-openapi");
|
||||
Logger.info(
|
||||
"🔄 Trying alternative approach with direct Go generation...",
|
||||
|
||||
@@ -99,7 +99,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
"Status Page lets you see real-time information about the status of our services.",
|
||||
faviconUrl: `/status-page-api/favicon/${statusPageIdOrDomain}`,
|
||||
};
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return {
|
||||
title: "Status Page",
|
||||
description:
|
||||
|
||||
@@ -18,7 +18,9 @@ const Banner: FunctionComponent<ComponentProps> = (
|
||||
<div>
|
||||
<Image
|
||||
onClick={() => {
|
||||
props.onClick && props.onClick();
|
||||
if (props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
}}
|
||||
className="rounded-xl w-full mt-5 mb-5"
|
||||
file={props.file}
|
||||
|
||||
@@ -33,7 +33,7 @@ import { GetReactElementFunction } from "Common/UI/Types/FunctionTypes";
|
||||
import SubscriberUtil from "Common/UI/Utils/StatusPage";
|
||||
import FormValues from "Common/UI/Components/Forms/Types/FormValues";
|
||||
|
||||
export interface ComponentProps extends SubscribePageProps {}
|
||||
export type ComponentProps = SubscribePageProps;
|
||||
|
||||
const SubscribePage: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
|
||||
@@ -29,16 +29,16 @@ export default class AddTelemetryServiceColor extends DataMigrationBase {
|
||||
|
||||
for (const service of services) {
|
||||
if (!service.serviceColor) {
|
||||
(service.serviceColor = ArrayUtil.selectItemByRandom(BrightColors)),
|
||||
await TelemetryServiceService.updateOneById({
|
||||
id: service.id!,
|
||||
data: {
|
||||
serviceColor: service.serviceColor,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
service.serviceColor = ArrayUtil.selectItemByRandom(BrightColors);
|
||||
await TelemetryServiceService.updateOneById({
|
||||
id: service.id!,
|
||||
data: {
|
||||
serviceColor: service.serviceColor,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user