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

Make VertexAIError error codes use the vertex type prefix #8542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dlarocque
Copy link
Contributor

@dlarocque dlarocque commented Sep 27, 2024

Since the code argument being passed (e.g. fetch-error) was readonly, it was overriding the prefixed error code that is set in the super constructor (vertexAI/fetch-error). So the error code users would see would not be prefixed. We should include the prefix, since that's what the other products do. Instead of fixing this by just making code not readonly, we should just add the prefix directly to the enum value, so that users can check error codes more safely. Otherwise they'd have access to the non-prefixed errors, and would have to prefix it themselves if they want to actually use it- if (err.code === 'vertexAI/${VertexAIErrorCode.FETCH_ERROR}') {...}

For example:

try {
  // ...
} catch (err) {
  if (err instanceof VertexAIError) {
    if (err.code === VertexAIErrorCode.FETCH_ERROR) { /* ... */ }
  }
}

@dlarocque dlarocque requested a review from a team as a code owner September 27, 2024 20:21
Copy link

changeset-bot bot commented Sep 27, 2024

⚠️ No Changeset found

Latest commit: ae29787

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

Size Report 1

Affected Products

  • @firebase/vertexai-preview

    TypeBase (beaa4df)Merge (a4089c2)Diff
    browser25.4 kB25.5 kB+110 B (+0.4%)
    main26.0 kB26.2 kB+110 B (+0.4%)
    module25.4 kB25.5 kB+110 B (+0.4%)
  • firebase

    TypeBase (beaa4df)Merge (a4089c2)Diff
    firebase-vertexai-preview.js19.6 kB19.7 kB+162 B (+0.8%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/C8ZDoHzyS1.html

@google-oss-bot
Copy link
Contributor

Size Analysis Report 1

Affected Products

  • @firebase/vertexai-preview

    • ChatSession

      Size

      TypeBase (beaa4df)Merge (a4089c2)Diff
      size14.1 kB14.2 kB+123 B (+0.9%)
      size-with-ext-deps32.6 kB32.8 kB+122 B (+0.4%)
    • GenerativeModel

      Size

      TypeBase (beaa4df)Merge (a4089c2)Diff
      size16.6 kB16.7 kB+141 B (+0.8%)
      size-with-ext-deps35.1 kB35.3 kB+140 B (+0.4%)
    • VertexAIError

      Size

      TypeBase (beaa4df)Merge (a4089c2)Diff
      size3.27 kB3.24 kB-30 B (-0.9%)
      size-with-ext-deps21.1 kB21.0 kB-31 B (-0.1%)
    • getGenerativeModel

      Size

      TypeBase (beaa4df)Merge (a4089c2)Diff
      size16.8 kB16.9 kB+150 B (+0.9%)
      size-with-ext-deps35.3 kB35.5 kB+149 B (+0.4%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/itG7HcZY6l.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants