-
Notifications
You must be signed in to change notification settings - Fork 0
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/extract abstract error handling #46
Conversation
packages/client/src/tools.js
Outdated
const contentType = result.headers.get('content-type'); | ||
throw new OpenReviewError({ | ||
name: 'ExtractAbstractError', | ||
message: (contentType && contentType.indexOf('application/json') !== -1) ? await result.json() : await result.text(), |
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 you have to get the message value from the json
message: (contentType && contentType.indexOf('application/json') !== -1) ? await result.json() : await result.text(), | |
message: (contentType && contentType.indexOf('application/json') !== -1) ? (await result.json()).message : await result.text(), |
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 wasn't sure if the json has the message property but I can do that.
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.
Done.
packages/client/src/tools.js
Outdated
@@ -882,8 +883,20 @@ export default class Tools { | |||
static extractAbstract(url) { | |||
const metaExtractionUrl = 'https://meta-extraction-wivlbyt6ga-uc.a.run.app/metadata'; | |||
const queryString = generateQueryString({ url }); | |||
return fetch(`${metaExtractionUrl}?${queryString}`, { | |||
const request = fetch(`${metaExtractionUrl}?${queryString}`, { |
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.
You could also change the extractAbstract function to be async and use await here 😬, but it's not necessary.
const request = fetch(`${metaExtractionUrl}?${queryString}`, { | |
const result = await fetch(`${metaExtractionUrl}?${queryString}`, { |
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.
Done!
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.
😬
const metaExtractionUrl = 'https://meta-extraction-wivlbyt6ga-uc.a.run.app/metadata'; | ||
const queryString = generateQueryString({ url }); | ||
return fetch(`${metaExtractionUrl}?${queryString}`, { | ||
const result = await fetch(`${metaExtractionUrl}?${queryString}`, { | ||
method: 'GET', |
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.
not related to this pr but i think the option param is redundant
Read the status code and throw an exception if it is different than 200.