Skip to content

fix: export REPError and document all getSecure() throw conditions#46

Merged
olamide226 merged 1 commit intomainfrom
fix/export-reperror-document-getsecure-throws
Mar 29, 2026
Merged

fix: export REPError and document all getSecure() throw conditions#46
olamide226 merged 1 commit intomainfrom
fix/export-reperror-document-getsecure-throws

Conversation

@olamide226
Copy link
Copy Markdown
Contributor

Summary

  • Exports REPError from @rep-protocol/sdk — it was defined but not exported, making instanceof REPError checks impossible for consumers
  • Documents all four getSecure() throw conditions in the SDK reference (key not found, endpoint unreachable, key expired, decryption failure)
  • Adds a complete try/catch example with correct REPError import

Test plan

  • Verify import { REPError } from '@rep-protocol/sdk' resolves after build
  • Verify instanceof REPError works in a catch block
  • Review docs example renders correctly in Astro/Starlight

REPError was not exported, making instanceof checks impossible for
consumers. Documents all four throw cases including key-not-found,
with a complete try/catch example in the SDK reference.
Copilot AI review requested due to automatic review settings March 29, 2026 01:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes REPError part of the public SDK surface so consumers can reliably import it, and updates the SDK reference docs to enumerate getSecure() failure modes and show a try/catch example using REPError.

Changes:

  • Export REPError from @rep-protocol/sdk (sdk/src/index.ts).
  • Expand getSecure() “Throws” documentation and add an example that imports REPError (docs/.../sdk.mdx).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/src/index.ts Makes REPError a named export so consumers can import it for error handling.
docs/src/content/docs/reference/sdk.mdx Updates getSecure() docs with explicit throw cases and a try/catch example referencing REPError.
Comments suppressed due to low confidence (1)

sdk/src/index.ts:51

  • Exporting REPError enables instanceof checks, but getSecure() can still reject with non-REPError exceptions (e.g. fetch() network rejections, invalid JSON/base64, WebCrypto import/decrypt errors). That makes consumer instanceof REPError handling incomplete and also conflicts with the docs’ claim that decryption/network failures throw REPError. Consider catching errors inside _loadSensitiveVars() (and the await _sensitiveLoadPromise path) and rethrowing a REPError (optionally using the cause field) so all getSecure() failures are consistently typed.
export class REPError extends Error {
  constructor(message: string) {
    super(`[REP] ${message}`);
    this.name = 'REPError';
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@olamide226 olamide226 merged commit fde97b8 into main Mar 29, 2026
13 checks passed
@olamide226 olamide226 deleted the fix/export-reperror-document-getsecure-throws branch March 29, 2026 02:13
@github-actions github-actions bot mentioned this pull request Mar 29, 2026
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