package com.capgemini.reports.formatting;

import lombok.extern.slf4j.Slf4j;

import com.capgemini.framework.common.FileTemplate;
import com.capgemini.framework.common.ResourceHelper;
import com.capgemini.reports.exceptions.FileLoadingException;

/** Template loader for HTML content in order to display an error in JSP. **/
@Slf4j
public class ErrorPageTemplate extends FileTemplate {

    /**
     * Constructor.
     * 
     * @param anErrorTitle Title of the error
     * @param anErrorMessage Content message for the current error
     */
    public ErrorPageTemplate(final String anErrorTitle, final String anErrorMessage) {

        super();

        // Select the corresponding template content 
        try {
            String theTemplateContent = ResourceHelper.getResourceContent("/html/error_jsp_page.html");
            setTemplateContent(theTemplateContent);
        }
        catch (FileLoadingException e) {
            log.warn("Could not load the Page template", e);
        }

        // Assign the expected template 

        // Set tag values 
        setTagValue("ERROR_TITLE", anErrorTitle);
        setTagValue("ERROR_MESSAGE", anErrorMessage);
    }
}
