-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Refactor error handling #159
Conversation
…/hubspot-local-dev-lib into jy/POC-Wrap-Axios-Errors
…jy/POC-Wrap-Axios-Errors
…jy/simplify-error-handling
…jy/POC-Wrap-Axios-Errors
lib/personalAccessKey.ts
Outdated
throwError(e); | ||
} | ||
} | ||
const response = await fetchAccessToken(personalAccessKey, env, accountId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great example of the value of this 🎉
this.context = { ...generatedContext, ...context }; | ||
} | ||
|
||
private parseValidationErrors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might need to dig into this parse validation util. I noticed that we're logging out some of the important context, but not all of it. For example:
Here's what logs out when I get a "missing scopes" error response. I can get this by trying to run this command against my developer portal, which doesn't have the right content scopes to access CMS data.
It's trying to tell me the scopes I'm missing, but it's not including all of the information that I need. This is the shape of responseData
when that happens:
context
here contains the scopes, like this: ["content", "content"]
(not sure why it's in there twice)
Also, from what I can tell, in the previous version of the error handling we only called it in a few places (throwApiUploadError is the only util that called isApiUploadValidationError, which ran this validation parsing logic). I wonder if it will have an impact on some of the existing error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a method to log the formattedValidationErrors that the CLI now calls if the error is a validation error.
I'll look into using the context object. How did you trigger missing scopes error? Just remove those scopes from the app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference to "app" here is misleading. In reality the error is referencing the personal access key. So you can generate a personal access key that doesn't have any scopes, and then try to run various CLI commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, really cleans things up nicely and should hopefully make the experience of using and contributing to local-dev-lib a lot better. I haven't tested yet, but I did my best to look over everything and didn't notice any problems. Are there any particular areas you need help with extra testing or that I should give a more focused look?
@camden11 Since it is such a wide spreading change, I think we really need to try to touch as many places as possible, so just widespread general testing. |
…ttedValidationErrors
…jy/simplify-error-handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still haven't had a chance to test this much, but assuming there will be plenty of time to text the next
branch if its not going to be merged for a bit.
Looked everything over again and LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lgtm! I did some testing locally and it all seems to be WAD. We'll have to hammer on it some more since it has a wide impact, but this is good to go into the next
branch 👌
Description and Context
Note: This will be a breaking change, so this PR is targeting the next branch and will be in the next major
Whats changed:
Removals
throwX
in a try block, which then obscures the intended error message with a new more generic error message. Methods removed:throwError
throwErrorWithMessage
throwApiError
throwApiUploadError
throwValidationError
throwAuthErrorWithMessage
throwFileSystemError
HubSpotAuthError
, because we now haveHubSpotHttpError
and we can check if it is an auth error usingisAuthError
in theerrors
moduleparseValidationErrors
is no longer exportedgetHubSpotHttpErrorWithContext
is no longer exportedAdditions
Error
objectFileSystemError
to replace the need forthrowFileSystemError
Changes
apiErrors
,standardErrors
, andfileSystemErrors
into a singleerrors
module.HubSpotHttpError
class and makes it an automatic operation.HubSpotHttpError
with have the user friendly http error message in it'smessage
property automatically.context
object is automatic on instantiation of theHubSpotHttpError
, but can be overriddenScreenshots
TODO
Who to Notify
@brandenrodgers @camden11 @kemmerle