[PR #805] Improve KomodoClient experience for URL and Error handling #792

Open
opened 2025-10-31 15:21:58 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/moghtech/komodo/pull/805
Author: @FoxxMD
Created: 9/4/2025
Status: 🔄 Open

Base: mainHead: apiClientImprove


📝 Commits (2)

  • e5f5552 feat: Make client URL usage more lenient
  • c9050c7 feat: Use proper Error class when throwing client response errors

📊 Changes

1 file changed (+65 additions, -18 deletions)

View changed files

📝 client/core/ts/src/lib.ts (+65 -18)

📄 Description

This PR improves the developer experience for using the komodo_client npm package:

  • Compensate for URLs with trailing slashes when joining api path
  • Implement a KomodoApiError class extending Error, used for api response rejection instead of plain object
    • Uses Error Cause for non-komodo errors
    • Error message is extracted from Serror, if present
    • Appends trace, if present, to stack string
    • Exposes response and SError as class fields

Many third party logging and network-wrapping libraries are used to handling rejected/thrown Error instances, so using a real Error means developers and end users get better readability and visibility into errors for free.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/moghtech/komodo/pull/805 **Author:** [@FoxxMD](https://github.com/FoxxMD) **Created:** 9/4/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `apiClientImprove` --- ### 📝 Commits (2) - [`e5f5552`](https://github.com/moghtech/komodo/commit/e5f5552e1cc4a292c560731ebc742f205119af42) feat: Make client URL usage more lenient - [`c9050c7`](https://github.com/moghtech/komodo/commit/c9050c73c6714fc2c629091ebf347e45f30a05ed) feat: Use proper Error class when throwing client response errors ### 📊 Changes **1 file changed** (+65 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `client/core/ts/src/lib.ts` (+65 -18) </details> ### 📄 Description This PR improves the developer experience for using the `komodo_client` npm package: * Compensate for URLs with trailing slashes when joining api path * Implement a `KomodoApiError` class extending `Error`, used for api response rejection instead of plain object * Uses Error Cause for non-komodo errors * Error message is extracted from Serror, if present * Appends trace, if present, to stack string * Exposes response and SError as class fields Many third party logging and network-wrapping libraries are used to handling rejected/thrown `Error` instances, so using a real `Error` means developers and end users get better readability and visibility into errors for free. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the
pull-request
label 2025-10-31 15:21:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#792
No description provided.