-
Notifications
You must be signed in to change notification settings - Fork 15
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
Prevent mention form from hanging forever #1393
Conversation
19a58d5
to
96295b6
Compare
return crossrefItemToMentionItem(item) | ||
try { | ||
return crossrefItemToMentionItem(item) | ||
} catch (e) { |
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.
Please remove e, it is unused
try{
...
} catch {
return null
}
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.
What should I put instead? It has to have a name and ESLint also complains when I use _
.
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.
What I mean change catch(e)
to just catch
because e
is not used.
The rest of the code remains unchanged.
export async function getUrlFromDoiOrg(doi: string) { | ||
try { | ||
const url = ` https://doi.org/api/handles/${encodeURIComponent(doi)}?type=URL` | ||
const resp = await fetch(url) | ||
// debugger | ||
if (resp.status === 200) { | ||
const json: DoiUrlResponse = await resp.json() | ||
// extract | ||
if (json.values.length > 0) { | ||
const item = json.values[0] | ||
if (item.type.toLowerCase() === 'url') { | ||
return item.data.value | ||
} | ||
} | ||
} | ||
} catch (e: any) { | ||
logger(`getUrlFromDoiOrg: ${e?.message}`, 'error') | ||
} | ||
} | ||
|
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 can also remove code from line 19-37 which is associated with this method
@@ -59,8 +61,12 @@ export default function FindMentionSection({id,config,findPublicationByTitle}:Fi | |||
const resp = await getMentionByDoi(searchFor) | |||
if (resp?.status === 200) { | |||
return [resp.message as MentionItemProps] | |||
} else { | |||
if (resp?.message) { | |||
showErrorMessage(resp.message) |
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.
Maybe extend/combine error messages. Currently the message is about missing title.
I think it would be more clear to say: "Failed to import/process mention. \n{err.message}"
Something like 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.
It works as described. I have few minor remarks.
96295b6
to
09d57b0
Compare
|
Prevent mention form from hanging forever
Changes proposed in this pull request
getUrlFromDoiOrg
How to test
docker compose down --volumes && docker compose build --parallel && docker compose up --scale data-generation=0
https://doi.org/10.61686/GOLUA29851
, this should result in an error message concerning its missing titleUnknown error
Part of #1384
PR Checklist:
docker-compose.yml