Migrate methods to RobloxAPIError class#855
Conversation
|
Yeah at this point I'm not really sure what else to do with this. Review time it is. |
|
Wow, big PR. Thanks - will review this weekend. From a quick read over, looking at ApiError (I know it hasn't changed in this PR but you authored it originally: function getResponseBody (data) {
if (typeof data.body === 'string') return data.body
try {
return JSON.stringify(data.body)
} catch {
throw Error('The passed response body is not a valid object')
}
}What is the behaviour here if the value passed is not a valid object? Is the actual API error returned from Roblox swallowed and the 'The passed response body is not a valid object' returned instead? Perhaps we could have the robloxApiError class as we currently do and another error class (like UnknownRobloxApiError) which exposes the raw text. |
It will get swallowed. However, anything returned by Roblox should not reach this point (as all requests made through |
|
Happy to approve once linting passes. Shall we also remove buy()? This will be a breaking change anyway |
|
Yeah that's fine I'll try to deal with linting tonight |
|
🎉 This PR is included in version 6.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* Request forwarding for CI (#863) * Add request manipulation for ci testing in http module * URL -> HOSTNAME and fix auth header * Here goes nothing * Curse you standard * Use node 22 for tests * Revert back to 20 22 works but none of the other workflows use it * URL -> HOSTNAME (again) * Make requests actually route through forwarder * Add api key to env * Move header setting to jar check * Actually fix it this time * Add comments on request forwarder * Fixes #864 (#865) Support caching the value `0` * Remove buy() (#867) * Delete lib/economy/buy.js * Remove BuyAssetResponse type * Remove BuyProductInfo and BuyAssetResponse * Remove it all this time * Migrate methods to RobloxAPIError class (#855) * Here goes nothing * Add caller getter to RobloxAPIError * Fix linting * Migrate canManage and configureItem * Redo error parsing for addDeveloperProduct * First attempt at new release system * BREAKING CHANGE: Document new versioning * fix: add release branches * ci: Add new release workflow BREAKING CHANGE: Trigger new major release to cover previously made major changes * fix: Update user block/unblock endpoints (#869) * feat: UserNotification Cloud API (#851) * Create new function * Updated and added typings * Fixed linting * Fixed linting electric boogaloo linting better be happy now... * Linting final touches of grace * Linting obliteration of an unworthy comma * Added typings to jsDocs * Fix error handling * Add test case for sendUserNotification * Remove extra await * Migrate to new error class --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> * feat: Add group ban methods (#872) * Create banFromGroup method * Create unbanFromGroup * Change return type of banFromGroup * Create getGroupBans * Add GroupBan type * Add function types for new methods * We need to actually return the response body * Change limit type to number getPageResults will accept numbers higher than 100 and will paginate * getPageResults only returns the data property * Change function type to accept number for limit * Add test cases for banFromGroup, getGroupBans, and unbanFromGroup * fix: Update user agent per Roblox's request (#870) * fix: Update user agent per Roblox's request * fix: Change header check for request forwarding UA enforcement means there will always be headers now * Add lock_ua setting * lock_ua -> use_noblox_ua * Set ua in request defaults if enabled * Le lint * Add user-agent documentation * Correct documentation --------- Co-authored-by: Josh Muir <josh@muir.xyz> * feat: Add getGroupPayoutEligibility (#834) * Add canpay function * Add PayoutAllowedList type to jsdocs * Fix formatting * canPay -> getGroupPayoutEligibility * Only log first error message from endpoint (as if Roblox ever returned more than one) * Fix type for PayoutAllowedList * Add function type for getGroupPayoutEligibility * Document jar param in getGroupPayoutEligibility * Update example * Move getGroupPayoutEligibility to economy * Update import for getGroupPayoutEligibility * Move function type to economy section * Add test case Arguments will most likely need to be adjusted but that's easy to do * Allow checking multiple users * Update typings part 1 * Update jsdoc * Migrate error handling --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> * fix: Final touches of error migration (#873) * Don't import buy.js * Apparently autocomplete didn't catch this one * Oh and migrate this too * Bump handlebars from 4.7.8 to 4.7.9 (#886) Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.8 to 4.7.9. - [Release notes](https://github.com/handlebars-lang/handlebars.js/releases) - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.9/release-notes.md) - [Commits](handlebars-lang/handlebars.js@v4.7.8...v4.7.9) --- updated-dependencies: - dependency-name: handlebars dependency-version: 4.7.9 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump undici from 6.21.2 to 6.24.1 (#883) Bumps [undici](https://github.com/nodejs/undici) from 6.21.2 to 6.24.1. - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](nodejs/undici@v6.21.2...v6.24.1) --- updated-dependencies: - dependency-name: undici dependency-version: 6.24.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump minimatch from 3.1.2 to 3.1.5 (#881) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump lodash from 4.17.21 to 4.17.23 (#879) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.21...4.17.23) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.17.23 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump picomatch from 2.3.1 to 2.3.2 (#885) Bumps [picomatch](https://github.com/micromatch/picomatch) from 2.3.1 to 2.3.2. - [Release notes](https://github.com/micromatch/picomatch/releases) - [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md) - [Commits](micromatch/picomatch@2.3.1...2.3.2) --- updated-dependencies: - dependency-name: picomatch dependency-version: 2.3.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump flatted from 3.3.3 to 3.4.2 (#884) Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.3 to 3.4.2. - [Commits](WebReflection/flatted@v3.3.3...v3.4.2) --- updated-dependencies: - dependency-name: flatted dependency-version: 3.4.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: Implement handleJoinRequests function for batch user join requests (#880) * feat: Implement handleJoinRequests function for batch user join request management * fix: Add missing newline at end of handleJoinRequests.js --------- Co-authored-by: realCartar <admin@softwareventures.com.au> * Update deprecated GitHub Actions to latest versions (#889) Bump actions/checkout from v2 to v4, actions/setup-node from v1 to v4, and actions/cache from v1 to v4 across doc-publish and npmpublish workflows. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * Switch npm publish to on dispatch only (#890) * Switch npm publish to on dispatch only * Add new release workflow v6.3.0 * Add new release workflow v6.3.0 * Add permissions * Switch to trusted publishing * v7.4.0 (#891) * Update action * Copy master over next (#895) * Next (#892) * First attempt at new release system * BREAKING CHANGE: Document new versioning * fix: add release branches * ci: Add new release workflow BREAKING CHANGE: Trigger new major release to cover previously made major changes * fix: Update user block/unblock endpoints (#869) * feat: UserNotification Cloud API (#851) * Create new function * Updated and added typings * Fixed linting * Fixed linting electric boogaloo linting better be happy now... * Linting final touches of grace * Linting obliteration of an unworthy comma * Added typings to jsDocs * Fix error handling * Add test case for sendUserNotification * Remove extra await * Migrate to new error class --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> * feat: Add group ban methods (#872) * Create banFromGroup method * Create unbanFromGroup * Change return type of banFromGroup * Create getGroupBans * Add GroupBan type * Add function types for new methods * We need to actually return the response body * Change limit type to number getPageResults will accept numbers higher than 100 and will paginate * getPageResults only returns the data property * Change function type to accept number for limit * Add test cases for banFromGroup, getGroupBans, and unbanFromGroup * fix: Update user agent per Roblox's request (#870) * fix: Update user agent per Roblox's request * fix: Change header check for request forwarding UA enforcement means there will always be headers now * Add lock_ua setting * lock_ua -> use_noblox_ua * Set ua in request defaults if enabled * Le lint * Add user-agent documentation * Correct documentation --------- Co-authored-by: Josh Muir <josh@muir.xyz> * feat: Add getGroupPayoutEligibility (#834) * Add canpay function * Add PayoutAllowedList type to jsdocs * Fix formatting * canPay -> getGroupPayoutEligibility * Only log first error message from endpoint (as if Roblox ever returned more than one) * Fix type for PayoutAllowedList * Add function type for getGroupPayoutEligibility * Document jar param in getGroupPayoutEligibility * Update example * Move getGroupPayoutEligibility to economy * Update import for getGroupPayoutEligibility * Move function type to economy section * Add test case Arguments will most likely need to be adjusted but that's easy to do * Allow checking multiple users * Update typings part 1 * Update jsdoc * Migrate error handling --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> * fix: Final touches of error migration (#873) * Don't import buy.js * Apparently autocomplete didn't catch this one * Oh and migrate this too * feat: Implement handleJoinRequests function for batch user join requests (#880) * feat: Implement handleJoinRequests function for batch user join request management * fix: Add missing newline at end of handleJoinRequests.js --------- Co-authored-by: realCartar <admin@softwareventures.com.au> * Update action --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> Co-authored-by: Commonly <51011212+commonly-ts@users.noreply.github.com> Co-authored-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com> Co-authored-by: Ethan <39052179+realCartar@users.noreply.github.com> Co-authored-by: realCartar <admin@softwareventures.com.au> * require lts (#893) * Update perms (#894) * Upgrade sem-rel: use trusted publishing --------- Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> Co-authored-by: Commonly <51011212+commonly-ts@users.noreply.github.com> Co-authored-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com> Co-authored-by: Ethan <39052179+realCartar@users.noreply.github.com> Co-authored-by: realCartar <admin@softwareventures.com.au> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Regalijan <72576136+Regalijan@users.noreply.github.com> Co-authored-by: mutex_lock <9419610+mutex-lock@users.noreply.github.com> Co-authored-by: Commonly <51011212+commonly-ts@users.noreply.github.com> Co-authored-by: supercoolspy <66487448+supercoolspy@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ethan <39052179+realCartar@users.noreply.github.com> Co-authored-by: realCartar <admin@softwareventures.com.au> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Currently draft because I may not be totally done but am open to help if someone is willing.
Does not include:
upload[thing]methods since those need new endpointsbuy()since it doesn't work anymore, requires multiple endpoints + 2fa, and is generally abused [eligible for removal]configureItemandcanManagesince those also need new endpoints