Skip to content

Commit

Permalink
692 Adds error reporting to forms submit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardovdheijden committed Dec 2, 2024
1 parent 6399156 commit c9a4c4c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
} from '@elastic/eui';

import { ConfirmDialogHandler, ConfirmationDialogContext } from '@/contexts';
import { useOrchestratorTheme } from '@/hooks';
import { useOrchestratorTheme, useWfoErrorMonitoring } from '@/hooks';
import { WfoPlayFill } from '@/icons';
import { FormValidationError, ValidationError } from '@/types/forms';

Expand Down Expand Up @@ -429,6 +429,7 @@ export function WfoUserInputForm({
const [processing, setProcessing] = useState<boolean>(false);
const [nrOfValidationErrors, setNrOfValidationErrors] = useState<number>(0);
const [rootErrors, setRootErrors] = useState<string[]>([]);
const { reportError } = useWfoErrorMonitoring();

const openLeavePageDialog = (
leaveAction: ConfirmDialogHandler,
Expand Down Expand Up @@ -457,7 +458,7 @@ export function WfoUserInputForm({
await validSubmit(userInput);
setProcessing(false);
return null;
} catch (error: unknown) {
} catch (error) {
setProcessing(false);
if (typeof error === 'object' && error !== null) {
const validationError = error as FormValidationError;
Expand Down Expand Up @@ -485,6 +486,9 @@ export function WfoUserInputForm({
}
// Let the error escape, so it can be caught by our own onerror handler instead of being silenced by uniforms
setTimeout(() => {
reportError(
new Error(`Forms error: ${JSON.stringify({ error })}`),
);
throw error;
}, 0);

Expand Down

0 comments on commit c9a4c4c

Please sign in to comment.