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

fix: second attempt at fixing the error handling in matchesHelper #2923

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
6 changes: 3 additions & 3 deletions packages/cli/src/lib/pg/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {APIClient} from '@heroku-cli/command'
import type {AddOnAttachment} from '@heroku-cli/schema'
import * as Heroku from '@heroku-cli/schema'
import {HerokuAPIError} from '@heroku-cli/command/lib/api-client'
import debug from 'debug'
import {AmbiguousError, appAttachment} from '../addons/resolve'
import {fetchConfig} from './bastion'
import {getConfig} from './config'
import color from '@heroku-cli/color'
import type {AddOnAttachmentWithConfigVarsAndPlan, AddOnWithRelatedData} from './types'
import {bastionKeyPlan, getConfigVarName, getConnectionDetails} from './util'
import {HTTPError} from 'http-call'

const pgDebug = debug('pg')

Expand Down Expand Up @@ -49,7 +49,7 @@ export async function all(heroku: APIClient, app_id: string): Promise<AddOnWithR
return addons
}

async function matchesHelper(heroku: APIClient, app: string, db: string, namespace?: string): Promise<{matches: AddOnAttachment[] | null, error?: AmbiguousError | HTTPError}> {
async function matchesHelper(heroku: APIClient, app: string, db: string, namespace?: string): Promise<{matches: AddOnAttachment[] | null, error?: AmbiguousError | HerokuAPIError}> {
debug(`fetching ${db} on ${app}`)

const addonService = process.env.HEROKU_POSTGRESQL_ADDON_NAME || 'heroku-postgresql'
Expand All @@ -62,7 +62,7 @@ async function matchesHelper(heroku: APIClient, app: string, db: string, namespa
return {matches: error.matches, error}
}

if (error instanceof HTTPError && error.statusCode === 404 && error.body && error.body.id === 'not_found') {
if (error instanceof HerokuAPIError && error.http.statusCode === 404 && error.body && error.body.id === 'not_found') {
return {matches: null, error}
}

Expand Down
Loading