Skip to content

Conversation

mathio
Copy link
Contributor

@mathio mathio commented Oct 9, 2023

Use custom Typeform.ApiError class to throw error with more details.

Resolves #56

Copy link
Contributor

@mumpo mumpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd take a completely different approach here. I'd create a TypeformError class extending Error that contains all the info returned from the API (error code, description and details).

If users want to do logging they can do it themselves like this:

try {
  const forms = await typeformClient.forms.list()
} catch (err: TypeformError) {
  console.log(err.code, err.description, err.details)
}

@mathio
Copy link
Contributor Author

mathio commented Oct 10, 2023

@mumpo makes sense, it introduces less complexity :)

image

@mathio mathio requested review from mumpo and Coralie-TF October 10, 2023 08:47
@mathio mathio marked this pull request as ready for review October 10, 2023 08:48
@mathio mathio requested a review from a team October 10, 2023 08:48
@mathio mathio changed the title feat(PR-40): provide customer error logger function feat(PR-40): throw custom error Oct 10, 2023
Use custom `Typeform.ApiError` class to throw error with more details.
@mathio mathio merged commit 6fd308f into main Oct 10, 2023
@mathio mathio deleted the logging branch October 10, 2023 10:59
@typeform-ops-gha
Copy link

🎉 This PR is included in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: More descriptive errors when a failure occurs
4 participants