Skip to content

Conversation

@FoxxMD
Copy link
Contributor

@FoxxMD FoxxMD commented Sep 4, 2025

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.

Compensate for URLs with trailing slashes when joining api path
* 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
@FoxxMD
Copy link
Contributor Author

FoxxMD commented Sep 4, 2025

The only thing I haven't accounted for here is if Komodo itself (through Action) expects the rejected object to be structured the old way. If this is the case I can add fields to the class to make its structure mirror the old way so Komodo can handle it without changing any other code.

@mbecker20
Copy link
Member

In bin/core/src/api/execute/action.rs, line 309 the Action does handle the catch case in hardcoded way. I think this change may affect this part and must be tested, could you include some test case / results?

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