Skip to content

Commit

Permalink
feat(bcf): add error handling for bcf import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed May 9, 2022
1 parent f69253c commit f0c771c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/i18n/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@
"subscriptionsFetchError": "Impossible de récupérer la liste des souscriptions",
"platformSubscribeError": "Erreur lors de la création du lien de souscription",
"datapackSubscribeError": "Échec de la souscription à un nouveau datapack",
"datapackUpdateError": "Erreur lors de la mise à jour du datapack"
"datapackUpdateError": "Erreur lors de la mise à jour du datapack",
"bcfImportError": "Une erreur s'est produite lors de l'import",
"bcfExportError": "L'export a échoué..."
}
}
5 changes: 3 additions & 2 deletions src/services/BcfService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { downloadBlobAs } from "@/utils/download.js";
import apiClient from "./api-client.js";
import { ERRORS, RuntimeError } from "./ErrorService.js";

class BcfService {
async fetchProjectTopics(project) {
Expand Down Expand Up @@ -62,7 +63,7 @@ class BcfService {
}
);
} catch (error) {
console.log(error);
throw new RuntimeError(ERRORS.BCF_IMPORT_ERROR, error);
}
}

Expand All @@ -71,7 +72,7 @@ class BcfService {
const response = await apiClient.bcfApi.downloadBcfExport(project.id);
downloadBlobAs(`${project.name}.bcf`, response);
} catch (error) {
console.log(error);
throw new RuntimeError(ERRORS.BCF_IMPORT_ERROR, error);
}
}
}
Expand Down
24 changes: 4 additions & 20 deletions src/services/ErrorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ const ERRORS = Object.freeze({
SUBSCRIPTIONS_FETCH_ERROR: "subscriptionsFetchError",
PLATFORM_SUBSCRIBE_ERROR: "platformSubscribeError",
DATAPACK_SUBSCRIBE_ERROR: "datapackSubscribeError",
DATAPACK_UPDATE_ERROR: "datapackUpdateError"
DATAPACK_UPDATE_ERROR: "datapackUpdateError",
BCF_IMPORT_ERROR: "bcfImportError",
BCF_EXPORT_ERROR: "bcfExportError"
});

class RuntimeError {
Expand All @@ -73,18 +75,6 @@ class RuntimeError {
}
}

class HttpClientError extends RuntimeError {
constructor(id, error) {
super(id, error);
}
}

class HttpServerError extends RuntimeError {
constructor(id, error) {
super(id, error);
}
}

class ErrorService {
constructor() {
this.t = i18n.global.t;
Expand All @@ -109,12 +99,6 @@ class ErrorService {

const service = new ErrorService();

export {
ERRORS,
RuntimeError,
HttpClientError,
HttpServerError,
service as ErrorService
};
export { ERRORS, RuntimeError, service as ErrorService };

export default service;

0 comments on commit f0c771c

Please sign in to comment.