improve exception details on io ops

This commit is contained in:
marhali 2022-02-03 16:40:43 +01:00
parent cd38515402
commit f3ab014e3f
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,9 @@
package de.marhali.easyi18n.util; package de.marhali.easyi18n.util;
import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diagnostic.Logger;
import de.marhali.easyi18n.ionext.IOHandler;
import de.marhali.easyi18n.model.SettingsState;
import org.jetbrains.annotations.NotNull;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -10,9 +13,12 @@ import java.util.ResourceBundle;
* @author marhali * @author marhali
*/ */
public class NotificationHelper { public class NotificationHelper {
public static void createIOError(String fileName, Class<?> ioStrategy, Exception ex) { public static void createIOError(@NotNull SettingsState state, Exception ex) {
ResourceBundle bundle = ResourceBundle.getBundle("messages"); ResourceBundle bundle = ResourceBundle.getBundle("messages");
String message = MessageFormat.format(bundle.getString("error.io"), fileName, ioStrategy.getSimpleName());
Logger.getInstance(ioStrategy).error(message, ex); String message = MessageFormat.format(bundle.getString("error.io"),
state.getFolderStrategy(), state.getParserStrategy(), state.getFilePattern(), state.getLocalesPath());
Logger.getInstance(IOHandler.class).error(message, ex);
} }
} }

View File

@ -25,4 +25,7 @@ settings.path.prefix=Path prefix
settings.keys.sort=Sort translation keys alphabetically settings.keys.sort=Sort translation keys alphabetically
settings.keys.nested=Escape delimiter character within a section layer. settings.keys.nested=Escape delimiter character within a section layer.
settings.editor.assistance=I18n key completion, annotation and reference inside editor settings.editor.assistance=I18n key completion, annotation and reference inside editor
error.io=Could not process file {0} with {1}. Unwanted files can be ignored via Translation file wildcard matcher option. error.io=An error occurred while processing translation files. \n\
Config: {0} => {1} ({2}) \n\
Path: {3} \n\
Please check examples at https://github.com/marhali/easy-i18n before reporting an issue!