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/extract abstract error handling #46

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

melisabok
Copy link
Member

Read the status code and throw an exception if it is different than 200.

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(),
Copy link
Member

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

Suggested change
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(),

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -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}`, {
Copy link
Member

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.

Suggested change
const request = fetch(`${metaExtractionUrl}?${queryString}`, {
const result = await fetch(`${metaExtractionUrl}?${queryString}`, {

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

@carlosmondra carlosmondra left a 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',
Copy link
Contributor

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

@xkopenreview xkopenreview merged commit d89b025 into master Apr 11, 2024
1 check passed
@melisabok melisabok deleted the fix/extract-abtract-error-handling branch April 11, 2024 20:25
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.

None yet

3 participants