Skip to content

Commit

Permalink
Show hint if parsing config fails
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Mar 18, 2024
1 parent 3deede1 commit 4e3ccc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ As this project is a user-facing application, the places in the semantic version
### Fixed

- Use the new Språkbanken Text logo
- Show hint if parsing config fails

## [1.4.0] (2024-03-11)

Expand Down
14 changes: 13 additions & 1 deletion src/corpus/config/config.composable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import {
emptyConfig,
makeConfig,
Expand All @@ -8,11 +9,14 @@ import {
import useLocale from "@/i18n/locale.composable";
import useMinkBackend from "@/api/backend.composable";
import { useResourceStore } from "@/store/resource.store";
import useMessenger from "@/message/messenger.composable";

export default function useConfig(corpusId: string) {
const resourceStore = useResourceStore();
const { t } = useI18n();
const { th } = useLocale();
const mink = useMinkBackend();
const { alert } = useMessenger();

const corpus = computed(() => resourceStore.corpora[corpusId]);
const config = computed(() => corpus.value?.config);
Expand All @@ -21,7 +25,15 @@ export default function useConfig(corpusId: string) {
async function loadConfig() {
const config = await mink
.loadConfig(corpusId)
.then(parseConfig)
.then(async (yaml: string) => {
try {
return await parseConfig(yaml);
} catch (e) {
console.error(`Parsing config failed: ${e}`);
alert(t("corpus.config.parse.error"));
return emptyConfig();
}
})
// 404 means no config which is fine, rethrow other errors.
.catch((error) => {
if (error.response?.status == 404) return emptyConfig();
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ resource.loading: Loading resource
resource.delete.ask: Are you sure you want to delete this resource?
config.metadata.help: Metadata is information about the data, meant for assessment by interested users (if you release the data), and for categorization in data repositories.
config.configuration.help: These settings are information for the automatic analysis; they will affect the parsing or annotation.
corpus.config.parse.error: The config of this corpus could not be parsed. Try editing the settings or metadata again. If you need help, please contact sb-info{'@'}svenska.gu.se
config.loading: Loading metadata
config.saving: Saving metadata
job.run: Run annotation
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ resource.loading: Laddar resurs
resource.delete.ask: Är du säker på att du vill ta bort den här resursen?
config.metadata.help: Metadata är information om datan, och fungerar som underlag för potentiellt intresserade användare (om du publicerar datan) samt underlättar katalogiseringen i datarepositorier.
config.configuration.help: Dessa inställningar blir instruktioner till den automatiska analysen.
corpus.config.parse.error: Korpusens config kunde inte läsas. Prova att redigera inställningarna eller metadatan igen. Om du behöver hjälp kan du kontakta sb-info{'@'}svenska.gu.se
config.loading: Hämtar metadata
config.saving: Sparar metadata
job.run: Starta annotering
Expand Down

0 comments on commit 4e3ccc2

Please sign in to comment.