Molunerfinn/PicGo · error

result.error (dynamic message propagated from RPC failure)

Error message

result.error (dynamic message propagated from RPC failure)

What it means

fetchPicGoCloudBillingOverview throws Error(result.error) when the PICGO_CLOUD_GET_BILLING_OVERVIEW RPC via cloudAdapter.getBillingOverview() reports success:false, surfacing the main-process failure text to TanStack Query. This turns a structured RPC failure envelope into a thrown error so the billing query transitions to error state.

Source

Thrown at src/renderer/queries/picgo-cloud-billing.ts:13

import { useQuery } from '@tanstack/react-query'
import type { IPicGoCloudBillingOverview } from '#/types/cloud'
import { cloudAdapter } from '@/adapters/cloud'
import { rendererQueryClient } from './query-client'

export const PicGoCloudBillingQueryKeys = {
  overview: ['picgo-cloud', 'billing'] as const
}

async function fetchPicGoCloudBillingOverview (): Promise<IPicGoCloudBillingOverview | null> {
  const result = await cloudAdapter.getBillingOverview()
  if (!result.success) {
    throw new Error(result.error)
  }
  return result.data
}

export function usePicGoCloudBillingQuery () {
  return useQuery({
    queryKey: PicGoCloudBillingQueryKeys.overview,
    queryFn: fetchPicGoCloudBillingOverview,
    refetchOnWindowFocus: true
  })
}

export async function invalidatePicGoCloudBillingQuery () {
  await rendererQueryClient.invalidateQueries({
    queryKey: PicGoCloudBillingQueryKeys.overview
  })
}

View on GitHub (pinned to 07ec7068a5)

Solutions

  1. Read query.error.message to identify the underlying failure (auth vs network vs server).
  2. Re-authenticate via cloudAdapter.login() then invalidate ['picgo-cloud','billing'].
  3. Retry after connectivity is restored; enable TanStack Query retry for transient errors.
  4. Handle null data gracefully — the fetcher returns IPicGoCloudBillingOverview | null on success, so only genuine failures throw.

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

const userInfo = rendererQueryClient.getQueryData<IPicGoCloudUserInfo | null>(['picgo-cloud', 'user-info'])
if (!userInfo) throw new Error('PicGo Cloud login required before fetching billing overview')

Type guard

function hasBillingData(r: unknown): r is { success: true, data: IPicGoCloudBillingOverview | null } {
  return typeof r === 'object' && r !== null && (r as { success?: boolean }).success === true
}

Try / catch

try {
  const overview = await rendererQueryClient.fetchQuery({ queryKey: ['picgo-cloud', 'billing'], queryFn: fetchPicGoCloudBillingOverview })
} catch (e) {
  toast.error(e instanceof Error ? e.message : i18n.t('OPERATION_FAILED'))
  // render an empty billing state instead of crashing the page
}

Prevention

When it happens

Trigger: Billing overview RPC fails: no PicGo Cloud session, token expired, billing service unreachable, server-side error for the account, or the main handler returns success:false with a message.

Common situations: Visiting the billing page while offline; session invalidated server-side; billing endpoint temporarily down; account in grace/frozen state that blocks billing data.

Related errors


AI-assisted analysis of Molunerfinn/PicGo@07ec7068a5 (2026-08-30). Data as JSON: /api/errors/f3c2ae30d8a0983b. Report an issue: GitHub.