diff --git a/web/projects/start-tunnel/src/app/routes/home/components/nav.ts b/web/projects/start-tunnel/src/app/routes/home/components/nav.ts index ec8d3e8b1..25f21db84 100644 --- a/web/projects/start-tunnel/src/app/routes/home/components/nav.ts +++ b/web/projects/start-tunnel/src/app/routes/home/components/nav.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core' import { Router, RouterLink, RouterLinkActive } from '@angular/router' -import { LoadingService } from '@start9labs/shared' +import { ErrorService, LoadingService } from '@start9labs/shared' import { TuiButton } from '@taiga-ui/core' import { ApiService } from 'src/app/services/api/api.service' import { AuthService } from 'src/app/services/auth.service' @@ -91,6 +91,7 @@ export class Nav { protected readonly sidebars = inject(SidebarService) protected readonly api = inject(ApiService) private readonly loader = inject(LoadingService) + private readonly errorService = inject(ErrorService) protected readonly routes = [ { @@ -121,8 +122,9 @@ export class Nav { await this.api.logout() this.service.authenticated.set(false) this.router.navigate(['.']) - } catch (e) { + } catch (e: any) { console.error(e) + this.errorService.handleError(e) } finally { loader.unsubscribe() } diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts b/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts index fc44325e4..59651c62b 100644 --- a/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts +++ b/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts @@ -10,7 +10,7 @@ import { ReactiveFormsModule, Validators, } from '@angular/forms' -import { LoadingService } from '@start9labs/shared' +import { ErrorService, LoadingService } from '@start9labs/shared' import { utils } from '@start9labs/start-sdk' import { TUI_IS_MOBILE, @@ -117,6 +117,7 @@ import { export class DevicesAdd { private readonly loading = inject(LoadingService) private readonly api = inject(ApiService) + private readonly errorService = inject(ErrorService) protected readonly mobile = inject(TUI_IS_MOBILE) protected readonly context = @@ -169,8 +170,9 @@ export class DevicesAdd { this.context.data.device ? await this.api.editDevice(data) : await this.api.addDevice(data) - } catch (e) { + } catch (e: any) { console.error(e) + this.errorService.handleError(e) } finally { loader.unsubscribe() this.context.$implicit.complete() diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/devices/index.ts b/web/projects/start-tunnel/src/app/routes/home/routes/devices/index.ts index 011d4768f..09063a376 100644 --- a/web/projects/start-tunnel/src/app/routes/home/routes/devices/index.ts +++ b/web/projects/start-tunnel/src/app/routes/home/routes/devices/index.ts @@ -6,7 +6,7 @@ import { Signal, } from '@angular/core' import { toSignal } from '@angular/core/rxjs-interop' -import { LoadingService } from '@start9labs/shared' +import { ErrorService, LoadingService } from '@start9labs/shared' import { TuiButton, TuiDataList, @@ -95,6 +95,7 @@ export default class Devices { private readonly dialogs = inject(TuiDialogService) private readonly api = inject(ApiService) private readonly loading = inject(LoadingService) + private readonly errorService = inject(ErrorService) protected readonly subnets: Signal = toSignal( inject>(PatchDB) @@ -148,8 +149,9 @@ export default class Devices { const data = await this.api.showDeviceConfig({ subnet: subnet.range, ip }) this.dialogs.open(DEVICES_CONFIG, { data }).subscribe() - } catch (e) { + } catch (e: any) { console.log(e) + this.errorService.handleError(e) } finally { loader.unsubscribe() } @@ -163,7 +165,8 @@ export default class Devices { const loader = this.loading.open().subscribe() try { await this.api.deleteDevice({ subnet: subnet.range, ip }) - } catch (e) { + } catch (e: any) { + this.errorService.handleError(e) console.log(e) } finally { loader.unsubscribe() diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts index 5c3e50b2a..e55a9ec64 100644 --- a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts +++ b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts @@ -5,7 +5,7 @@ import { ReactiveFormsModule, Validators, } from '@angular/forms' -import { LoadingService } from '@start9labs/shared' +import { ErrorService, LoadingService } from '@start9labs/shared' import { TUI_IS_MOBILE, tuiMarkControlAsTouchedAndValidate, @@ -135,6 +135,7 @@ import { MappedDevice, PortForwardsData } from './utils' export class PortForwardsAdd { private readonly api = inject(ApiService) private readonly loading = inject(LoadingService) + private readonly errorService = inject(ErrorService) protected readonly mobile = inject(TUI_IS_MOBILE) protected readonly context = @@ -166,8 +167,9 @@ export class PortForwardsAdd { source: `${externalip}:${externalport}`, target: `${device?.ip}:${internalport}`, }) - } catch (e) { + } catch (e: any) { console.error(e) + this.errorService.handleError(e) } finally { loader.unsubscribe() this.context.$implicit.complete() diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/index.ts b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/index.ts index f28357df4..e5b2ae735 100644 --- a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/index.ts +++ b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/index.ts @@ -7,7 +7,7 @@ import { } from '@angular/core' import { toSignal } from '@angular/core/rxjs-interop' import { ReactiveFormsModule } from '@angular/forms' -import { LoadingService } from '@start9labs/shared' +import { ErrorService, LoadingService } from '@start9labs/shared' import { utils } from '@start9labs/start-sdk' import { TuiButton } from '@taiga-ui/core' import { TuiDialogService } from '@taiga-ui/experimental' @@ -67,6 +67,8 @@ export default class PortForwards { private readonly api = inject(ApiService) private readonly loading = inject(LoadingService) private readonly patch = inject>(PatchDB) + private readonly errorService = inject(ErrorService) + private readonly portForwards = toSignal(this.patch.watch$('portForwards')) private readonly ips = toSignal( this.patch.watch$('gateways').pipe( @@ -128,8 +130,9 @@ export default class PortForwards { try { await this.api.deleteForward({ source }) - } catch (e) { + } catch (e: any) { console.log(e) + this.errorService.handleError(e) } finally { loader.unsubscribe() } diff --git a/web/projects/start-tunnel/src/app/services/api/live-api.service.ts b/web/projects/start-tunnel/src/app/services/api/live-api.service.ts index 5f44cd165..7c8ee6970 100644 --- a/web/projects/start-tunnel/src/app/services/api/live-api.service.ts +++ b/web/projects/start-tunnel/src/app/services/api/live-api.service.ts @@ -4,6 +4,7 @@ import { RPCOptions, isRpcError, RpcError, + ErrorService, } from '@start9labs/shared' import { filter, firstValueFrom, Observable } from 'rxjs' import { webSocket } from 'rxjs/webSocket' @@ -29,6 +30,7 @@ export class LiveApiService extends ApiService { private readonly document = inject(DOCUMENT) private readonly auth = inject(AuthService) private readonly cache$ = inject(PATCH_CACHE) + private readonly errorService = inject(ErrorService) constructor() { super()