noblox.js icon indicating copy to clipboard operation
noblox.js copied to clipboard

Migrate methods to RobloxAPIError class

Open Regalijan opened this issue 10 months ago • 1 comments

Currently draft because I may not be totally done but am open to help if someone is willing.

Does not include:

  • Anything involving SignalR (will possibly make something else for this)
  • upload[thing] methods since those need new endpoints
  • buy() since it doesn't work anymore, requires multiple endpoints + 2fa, and is generally abused [eligible for removal]
  • configureItem and canManage since those also need new endpoints

Regalijan avatar Jan 02 '25 06:01 Regalijan

Yeah at this point I'm not really sure what else to do with this.

Review time it is.

Regalijan avatar May 05 '25 20:05 Regalijan

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.

Neztore avatar Jul 22 '25 20:07 Neztore

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 http come back as full responses [which have string/non-parsed bodies]). It is a failsafe against people misusing it, e.g. importing the class and passing a date object as the body.

Regalijan avatar Jul 23 '25 04:07 Regalijan

Happy to approve once linting passes. Shall we also remove buy()? This will be a breaking change anyway

Neztore avatar Jul 27 '25 21:07 Neztore

Yeah that's fine

I'll try to deal with linting tonight

Regalijan avatar Jul 27 '25 21:07 Regalijan

:tada: This PR is included in version 6.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Aug 01 '25 22:08 github-actions[bot]