Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to throw based global error handling #146

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use app_state::{AppState, AppStateInner};
use sage_api::SyncEvent;
use tauri::Manager;
use tauri_specta::{collect_commands, collect_events, Builder};
use tauri_specta::{collect_commands, collect_events, Builder, ErrorHandlingMode};
use tokio::sync::Mutex;

mod app_state;
Expand All @@ -14,6 +14,7 @@ use specta_typescript::{BigIntExportBehavior, Typescript};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let builder = Builder::<tauri::Wry>::new()
.error_handling(ErrorHandlingMode::Throw)
// Then register them (separated by a comma)
.commands(collect_commands![
commands::initialize,
Expand Down
33 changes: 21 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import {
RouterProvider,
} from 'react-router-dom';
import { useLocalStorage } from 'usehooks-ts';
import { ErrorProvider } from './contexts/ErrorContext';
import { PeerProvider } from './contexts/PeerContext';
import { PriceProvider } from './contexts/PriceContext';
import { WalletConnectProvider } from './contexts/WalletConnectContext';
import useInitialization from './hooks/useInitialization';
import { useWallet } from './hooks/useWallet';
import Addresses from './pages/Addresses';
import Collection from './pages/Collection';
import CreateProfile from './pages/CreateProfile';
import CreateWallet from './pages/CreateWallet';
Expand All @@ -24,7 +26,6 @@ import Nft from './pages/Nft';
import { NftList } from './pages/NftList';
import { Offers } from './pages/Offers';
import PeerList from './pages/PeerList';
import Addresses from './pages/Addresses';
import Send from './pages/Send';
import Settings from './pages/Settings';
import Token from './pages/Token';
Expand Down Expand Up @@ -105,6 +106,16 @@ export default function App() {
root.classList.add(dark ? 'dark' : 'light');
}, [dark]);

return (
<DarkModeContext.Provider value={darkMode}>
<ErrorProvider>
<AppInner />
</ErrorProvider>
</DarkModeContext.Provider>
);
}

function AppInner() {
const initialized = useInitialization();
const wallet = useWallet(initialized);

Expand All @@ -115,16 +126,14 @@ export default function App() {
}, [wallet]);

return (
<DarkModeContext.Provider value={darkMode}>
{initialized && (
<PeerProvider>
<WalletConnectProvider>
<PriceProvider>
<RouterProvider router={router} />
</PriceProvider>
</WalletConnectProvider>
</PeerProvider>
)}
</DarkModeContext.Provider>
initialized && (
<PeerProvider>
<WalletConnectProvider>
<PriceProvider>
<RouterProvider router={router} />
</PriceProvider>
</WalletConnectProvider>
</PeerProvider>
)
);
}
Loading
Loading