mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix: Replace hardcoded "Monitor not found" messages with centralized exception messages
This commit is contained in:
@@ -12,6 +12,7 @@ import React, {
|
||||
} from "react";
|
||||
import MonitorStatusElement from "./MonitorStatusElement";
|
||||
import Loader, { LoaderType } from "Common/UI/Components/Loader/Loader";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
|
||||
export interface ComponentProps {
|
||||
monitorId: ObjectID;
|
||||
@@ -45,7 +46,7 @@ const GetMonitorStatusElement: FunctionComponent<ComponentProps> = (
|
||||
|
||||
if (!monitor) {
|
||||
setIsLoading(false);
|
||||
setError("Monitor not found");
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import { useAsyncEffect } from "use-async-effect";
|
||||
import MonitorTestForm from "../../../Components/Form/Monitor/MonitorTest";
|
||||
import Probe from "Common/Models/DatabaseModels/Probe";
|
||||
@@ -61,7 +62,7 @@ const MonitorCriteria: FunctionComponent<
|
||||
});
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
|
||||
const MonitorDocumentation: FunctionComponent<
|
||||
@@ -55,7 +56,7 @@ const MonitorDocumentation: FunctionComponent<
|
||||
setMonitor(item);
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
import RouteMap, { RouteUtil } from "../../../Utils/RouteMap";
|
||||
import PageMap from "../../../Utils/PageMap";
|
||||
@@ -215,7 +216,7 @@ const MonitorView: FunctionComponent<PageComponentProps> = (): ReactElement => {
|
||||
);
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
|
||||
const MonitorCriteria: FunctionComponent<
|
||||
@@ -48,7 +49,7 @@ const MonitorCriteria: FunctionComponent<
|
||||
});
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import ModelAPI from "Common/UI/Utils/ModelAPI/ModelAPI";
|
||||
import Navigation from "Common/UI/Utils/Navigation";
|
||||
import Monitor from "Common/Models/DatabaseModels/Monitor";
|
||||
import React, { FunctionComponent, ReactElement, useState } from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import { Outlet, useParams } from "react-router-dom";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
|
||||
@@ -43,7 +44,7 @@ const MonitorViewLayout: FunctionComponent = (): ReactElement => {
|
||||
setMonitor(item);
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
import AnalyticsModelTable from "Common/UI/Components/ModelTable/AnalyticsModelTable";
|
||||
import SummaryInfo from "../../../Components/Monitor/SummaryView/SummaryInfo";
|
||||
@@ -55,7 +56,7 @@ const MonitorLogs: FunctionComponent<PageComponentProps> = (): ReactElement => {
|
||||
});
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import React, {
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
import SummaryInfo from "../../../Components/Monitor/SummaryView/SummaryInfo";
|
||||
import ProbeMonitorResponse from "Common/Types/Probe/ProbeMonitorResponse";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
|
||||
const MonitorProbes: FunctionComponent<
|
||||
PageComponentProps
|
||||
@@ -61,7 +62,7 @@ const MonitorProbes: FunctionComponent<
|
||||
});
|
||||
|
||||
if (!item) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import React, {
|
||||
ReactElement,
|
||||
useState,
|
||||
} from "react";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import useAsyncEffect from "use-async-effect";
|
||||
import OneUptimeDate from "Common/Types/Date";
|
||||
|
||||
@@ -61,7 +62,7 @@ const MonitorCriteria: FunctionComponent<
|
||||
});
|
||||
|
||||
if (!monitor) {
|
||||
setError(`Monitor not found`);
|
||||
setError(ExceptionMessages.MonitorNotFound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import HTTPMethod from "Common/Types/API/HTTPMethod";
|
||||
import OneUptimeDate from "Common/Types/Date";
|
||||
import Dictionary from "Common/Types/Dictionary";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
import IncomingMonitorRequest from "Common/Types/Monitor/IncomingMonitor/IncomingMonitorRequest";
|
||||
import MonitorType from "Common/Types/Monitor/MonitorType";
|
||||
@@ -85,7 +86,7 @@ async function processIncomingRequestFromQueue(
|
||||
});
|
||||
|
||||
if (!monitor || !monitor._id) {
|
||||
throw new BadDataException("Monitor not found");
|
||||
throw new BadDataException(ExceptionMessages.MonitorNotFound);
|
||||
}
|
||||
|
||||
if (!monitor.projectId) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
import MonitorType from "Common/Types/Monitor/MonitorType";
|
||||
import ObjectID from "Common/Types/ObjectID";
|
||||
@@ -50,7 +51,7 @@ router.get(
|
||||
});
|
||||
|
||||
if (!monitor) {
|
||||
throw new BadDataException("Monitor not found");
|
||||
throw new BadDataException(ExceptionMessages.MonitorNotFound);
|
||||
}
|
||||
|
||||
return Response.sendEmptySuccessResponse(req, res);
|
||||
|
||||
@@ -3,6 +3,7 @@ import logger from "Common/Server/Utils/Logger";
|
||||
import { QueueJob, QueueName } from "Common/Server/Infrastructure/Queue";
|
||||
import QueueWorker from "Common/Server/Infrastructure/QueueWorker";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
import ExceptionMessages from "Common/Types/Exception/ExceptionMessages";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
import JSONFunctions from "Common/Types/JSONFunctions";
|
||||
import MonitorType from "Common/Types/Monitor/MonitorType";
|
||||
@@ -66,7 +67,7 @@ async function processServerMonitorFromQueue(
|
||||
});
|
||||
|
||||
if (!monitor) {
|
||||
throw new BadDataException("Monitor not found");
|
||||
throw new BadDataException(ExceptionMessages.MonitorNotFound);
|
||||
}
|
||||
|
||||
const serverMonitorResponse: ServerMonitorResponse =
|
||||
|
||||
Reference in New Issue
Block a user