Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
catosaurusrex2003 committed Nov 13, 2024
1 parent 338df63 commit 305eca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
28 changes: 9 additions & 19 deletions library/src/containers/ApplicationErrorHandler/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
import React from 'react';
import { ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
import { ErrorObject } from '../../types';
import { Error } from '../Error/Error';

interface Props {
children: ReactNode;
}

interface FallbackProps {
error: any;
resetErrorBoundary?: (...args: any[]) => void;
}

function fallbackRender({ error, resetErrorBoundary }: FallbackProps) {
function fallbackRender({ error }: FallbackProps) {
const ErrorObject: ErrorObject = {
title: "Something went wrong",
title: 'Something went wrong',
type: 'application-error',
validationErrors:[
validationErrors: [
{
title:error.message,
}
]
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
title: error?.message,
},
],
};
return <Error error={ErrorObject} />;
}

const AsyncApiErrorBoundary = ({ children }: Props) => {
const onReset = (details: any) => {
// TODO: maybe some magic to recover the previous document ( the one without the error ) automatically
};

return (
<ErrorBoundary fallbackRender={fallbackRender} onReset={onReset}>
{children}
</ErrorBoundary>
<ErrorBoundary fallbackRender={fallbackRender}>{children}</ErrorBoundary>
);
};

Expand Down
2 changes: 1 addition & 1 deletion library/src/containers/Error/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const renderErrors = (errors: ValidationError[]): React.ReactNode => {
}
return (
<div key={index} className="flex gap-2">
{(singleError?.location?.startLine ||
{(singleError?.location?.startLine ??
singleError?.location?.startOffset) && (
<span>{`line ${singleError?.location?.startLine + singleError?.location?.startOffset}:`}</span>
)}
Expand Down

0 comments on commit 305eca0

Please sign in to comment.