Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/workflow-basics/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,12 @@ export default class WorkflowBasics extends Component<WorkflowBasicsSignature> {
{{on 'input' this.handleDoiInput}}
/>
<div class='text-danger'>
{{if (and @publication.doi (not this.isValidDOI)) 'Please provide a valid DOI'}}
{{if (and @publication.doi (not this.isValidDOI) (not this.doiServiceError)) 'Please provide a valid DOI'}}
</div>
{{#if this.doiServiceError}}
<div class='text-danger'>
{{! @glint-expect-error - doiServiceError is unknown but rendered as HTML }}
{{{this.doiServiceError}}}
{{{this.doiServiceError.message}}}
</div>
{{/if}}
</div>
Expand Down
14 changes: 14 additions & 0 deletions app/services/doi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ export default class DoiService extends Service {
},
});

if (rawResponse.status === 404) {
throw new Error('DOI not found.');
}

if (rawResponse.status === 422) {
throw new Error(
'Unable to find a journal associated with the DOI. The DOI must resolve to an article or manuscript.',
);
}

if (rawResponse.status === 500) {
throw new Error('Error accessing DOI service.');
}

const response = await rawResponse.json();

const { content: journalDoc } = await this.store.request(findRecord('journal', response['journal-id']));
Expand Down
Loading