Skip to content
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

refactor(errors) increases verbosity of error messages to help debugging #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MattGson
Copy link

@MattGson MattGson commented May 27, 2021

I've added some more details into error messages where I got tripped up.
I ended up digging through the source code to debug which isn't ideal.

Let me know if you have any feedback.

fixes #123

@MattGson MattGson force-pushed the master branch 3 times, most recently from 6300cb7 to 1bf8264 Compare May 27, 2021 22:52
@@ -91,7 +91,9 @@ export const schemaFromConfluentSchema = (
break
}
default:
throw new ConfluentSchemaRegistryArgumentError('invalid schemaType')
throw new ConfluentSchemaRegistryArgumentError(
`invalid schemaType ${(confluentSchema as ConfluentSchema).type}`,
Copy link
Member

Choose a reason for hiding this comment

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

Why would you need to cast this when confluentSchema is already a ConfluentSchema according to the function parameter definition?

@@ -4,6 +4,8 @@ interface ConfluenceResponse extends Omit<Response, 'data'> {
data: () => {
message: string
}
responseData?: unknown
errors?: unknown[]
Copy link
Member

@Nevon Nevon Jun 1, 2021

Choose a reason for hiding this comment

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

I don't see the errors field on the Response type:

https://github.com/tulios/mappersmith/blob/18abaca9b987b0d71301b9582b490b256edfc42e/typings/index.d.ts#L62-L74

There is an error field, but no errors. There is an errors property in the JS object, but since it's not exposed in the types, I would take that to mean it's a private property that we shouldn't be accessing.

Same with the responseData field. There is a rawData method that's exposed that we could use, but I'm not sure why we'd both access data and rawData, and not just the former.

Copy link
Member

Choose a reason for hiding this comment

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

In fact, I think this type can be replaced with just referencing the Response type directly, since this type doesn't actually do anything meaningful. The data method is already a generic that allows you to define the return type.

@@ -0,0 +1,6029 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

This project uses yarn and should not have an npm lockfile committed.

@@ -1,13 +1,13 @@
import avro from 'avsc'
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this being used anywhere.

@@ -12,7 +14,14 @@ class ResponseError extends Error {
url: string

constructor(clientName: string, response: ConfluenceResponse) {
super(`${clientName} - ${response.data().message || `Error, status ${response.status()}`}`)
super(
Copy link
Member

@Nevon Nevon Jun 1, 2021

Choose a reason for hiding this comment

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

This change has caused some tests to fail that need to be updated.

The final string now has a trailing space if there are no errors. I would suggest the following instead:

`Error, status ${response.status()}${response.error() ? `: ${response.error()}` : ''}`

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.

Errors are very minimalistic and hard to debug with
2 participants