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

fix: better error messages #97

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

ffMathy
Copy link
Contributor

@ffMathy ffMathy commented Apr 5, 2023

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

I was trying to use the awesome and brand new Schema Generator (https://github.com/ftrackhq/ftrack-ts-schema-generator).

However, I got the following error:

Failed to perform request.  CustomError [ServerError]: fetch failed
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:561:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}
Server reported error in unexpected format.  CustomError [ServerError]: fetch failed
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:561:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}
/Users/Documents/src/ftrack-javascript/source/session.ts:336
    const error = new ErrorClass(response.content, response.error_code);
                  ^
CustomError [ServerError]: fetch failed
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:588:20)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}

This wasn't very useful, so I made this pull request. After that pull request, the error was instead way more helpful:

Failed to perform request.  CustomError [ServerError]: Error: unable to verify the first certificate
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:561:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}
Server reported error in unexpected format.  CustomError [ServerError]: Error: unable to verify the first certificate
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:561:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}
/Users/Documents/src/ftrack-javascript/source/session.ts:336
    const error = new ErrorClass(response.content, response.error_code);
                  ^
CustomError [ServerError]: Error: unable to verify the first certificate
    at Session.getErrorFromResponse (/Users/Documents/src/ftrack-javascript/source/session.ts:336:19)
    at Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:588:20)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Session.call (/Users/Documents/src/ftrack-javascript/source/session.ts:534:5)
    at async Session.query (/Users/Documents/src/ftrack-javascript/source/session.ts:738:23) {
  errorCode: undefined
}

This allowed me to truly figure out that it was a company-related VPN thing that caused the issue, and that I needed some certificate changes.

Test

I tried the following test - it provides a much better error message now:

import { Session } from '@ftrack/api';

const client = new Session();
client.query("select id from Project").then(console.log);

@ffMathy ffMathy requested a review from a team as a code owner April 5, 2023 13:30
Copy link
Contributor

@gismya gismya left a comment

Choose a reason for hiding this comment

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

Could it be beneficial to include both the message and the cause?

@ffMathy
Copy link
Contributor Author

ffMathy commented Apr 6, 2023

Yes - I'll fix that Monday. But feel free to add it already! 😄

@ffMathy
Copy link
Contributor Author

ffMathy commented Apr 6, 2023

@gismya actually, I remember now why I didn't do it. I tried it at first, but the cause also seems to include the message and/or the stack trace?

I do at least remember that the error looked duplicated when I included both.

Not sure if that's still what we want. But up to you! 🙏

@gismya gismya merged commit 13479dd into ftrackhq:main Apr 13, 2023
@ffMathy
Copy link
Contributor Author

ffMathy commented Apr 13, 2023

Hmm doesn't seem like this one was published. Maybe it didn't pass?

@gismya
Copy link
Contributor

gismya commented Apr 14, 2023

I just hadn't approved the new release - should be out now.

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.

2 participants