npm package diff
Package: @forge/i18n
Versions: 0.0.4 - 0.0.5-next.0
File: package/out/translationsGetter.js
Index: package/out/translationsGetter.js
===================================================================
--- package/out/translationsGetter.js
+++ package/out/translationsGetter.js
@@ -1,12 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.TranslationsGetter = void 0;
+exports.TranslationsGetter = exports.TranslationGetterError = void 0;
const pushIfNotExists = (array, item) => {
if (!array.includes(item)) {
array.push(item);
}
};
+class TranslationGetterError extends Error {
+ constructor(message) {
+ super(message);
+ this.name = 'TranslationGetterError';
+ }
+}
+exports.TranslationGetterError = TranslationGetterError;
class TranslationsGetter {
resourcesAccessor;
i18nInfoConfig = null;
translationResources = new Map();
@@ -62,9 +69,12 @@
resource = await this.resourcesAccessor.getTranslationResource(locale);
this.translationResources.set(locale, resource);
}
catch (error) {
- throw new Error(`Failed to get translation resource for locale: ${locale}`);
+ if (error instanceof TranslationGetterError) {
+ throw error;
+ }
+ throw new TranslationGetterError(`Failed to get translation resource for locale: ${locale}`);
}
}
return resource;
}
@@ -73,9 +83,12 @@
try {
this.i18nInfoConfig = await this.resourcesAccessor.getI18nInfoConfig();
}
catch (error) {
- throw new Error('Failed to get i18n info config');
+ if (error instanceof TranslationGetterError) {
+ throw error;
+ }
+ throw new TranslationGetterError('Failed to get i18n info config');
}
}
return this.i18nInfoConfig;
}