-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { Component, ReactNode } from 'react'; | ||
|
||
interface ErrorBoundaryProperties { | ||
children: ReactNode; | ||
} | ||
|
||
interface ErrorBoundaryState { | ||
hasError: boolean; | ||
error: Error | null; | ||
} | ||
|
||
class ErrorBoundary extends Component< | ||
ErrorBoundaryProperties, | ||
ErrorBoundaryState | ||
> { | ||
constructor(properties: ErrorBoundaryProperties) { | ||
super(properties); | ||
this.state = { hasError: false, error: null }; | ||
} | ||
|
||
static getDerivedStateFromError(error: Error) { | ||
return { hasError: true, error }; | ||
} | ||
|
||
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { | ||
console.error('Error caught by ErrorBoundary:', error, errorInfo); | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
return ( | ||
<div className="p-4 border-red-500 border-2 rounded-md bg-red-100 h-full"> | ||
<p className="font-bold">STL Preview Error</p> | ||
<p>Error loading STL file:</p> | ||
<code>{this.state.error?.message}</code> | ||
</div> | ||
); | ||
} | ||
|
||
return this.props.children; | ||
} | ||
} | ||
|
||
export { ErrorBoundary }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters