Skip to content

Commit

Permalink
feat(web): improve message in GitHub URL errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Sep 5, 2023
1 parent 603ffa0 commit 23cb227
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages_rs/nextclade-web/src/io/fetchSingleDatasetFromGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,13 @@ export function isGithubUrlOrShortcut(url: string): boolean {
return !isNil(/^(github:|gh:|https?:\/\/github.com).*/.exec(url))
}

const GITHUB_URL_EXAMPLE =
'https://github.com/nextstrain/nextclade_data/tree/6ab9560b86e3384792235fa72d1c3eaf30e71213/data/datasets/flu_yam_ha/references/JN993010/versions/2022-07-27T12:00:00Z/files/'

const GITHUB_URL_ERROR_HINTS = ` Check the correctness of the URL. If you don't intend to use custom dataset, remove the parameter from the address or restart the application. An example of a correct URL: '${GITHUB_URL_EXAMPLE}'`
const GITHUB_URL_ERROR_HINTS = ` Check the correctness of the URL. If it's a full GitHub URL, please try to navigate to it - you should see a GitHub repo branch with your files listed. If it's a GitHub URL shortcut, please double check the syntax. See documentation for the correct syntax and examples. If you don't intend to use custom datasets, remove the parameter from the address or restart the application.`

export class ErrorDatasetGithubUrlPatternInvalid extends Error {
public readonly datasetGithubUrl: string

constructor(datasetGithubUrl: string) {
super(
`Dataset GitHub URL (provided using 'dataset-url' URL parameter) is invalid: '${datasetGithubUrl}'.` +
GITHUB_URL_ERROR_HINTS,
)
super(`Dataset GitHub URL is invalid: '${datasetGithubUrl}'.${GITHUB_URL_ERROR_HINTS}`)
this.datasetGithubUrl = datasetGithubUrl
}
}
Expand All @@ -122,9 +116,7 @@ export class ErrorDatasetGithubUrlComponentsInvalid extends Error {
.join(',')

super(
`Dataset GitHub URL (provided using 'dataset-url' URL parameter) is invalid: '${datasetGithubUrl}'.` +
` Detected the following components ${componentsListStr}.` +
GITHUB_URL_ERROR_HINTS,
`Dataset GitHub URL is invalid: '${datasetGithubUrl}'. Detected the following components ${componentsListStr}.${GITHUB_URL_ERROR_HINTS}`,
)
this.datasetGithubUrl = datasetGithubUrl
this.parsedRepoUrlComponents = parsedRepoUrlComponents
Expand Down

0 comments on commit 23cb227

Please sign in to comment.