package org.javarosa.xml.util;

import org.javarosa.core.services.locale.Localization;

/**
 * Invalid structure error that can _potentially_ be recovered from via
 * advanced user intervention. Useful for notifying the user that the issue lies
 * on the server.
 *
 * @author Phillip Mates (pmates@dimagi.com).
 */
public class ActionableInvalidStructureException extends InvalidStructureException {
    private String localizationKey;
    private String[] localizationParameters;

    public ActionableInvalidStructureException(String localizationKey,
                                                String[] localizationParameters,
                                                String message) {
        super(message);
        this.localizationKey = localizationKey;
        this.localizationParameters = localizationParameters;
    }

    @Override
    public String getLocalizedMessage() {
        if (localizationKey != null) {
            return Localization.get(localizationKey, localizationParameters);
        } else {
            return getMessage();
        }
    }
}

@@ -79,16 +79,72 @@
 ization;
+%0Aimport org.javarosa.core.util.NoLocalizedTextException;
 %0A%0A/**%0A *
@@ -982,24 +982,46 @@
  != null) %7B%0A
+            try %7B%0A    
             
@@ -1086,16 +1086,118 @@
 eters);%0A
+            %7D catch (NoLocalizedTextException e) %7B%0A                return getMessage();%0A            %7D%0A
         

Add error handling for localization failures