001    package com.khubla.pragmatach.framework.controller.impl.system;
002    
003    import java.util.HashMap;
004    import java.util.Map;
005    
006    import com.khubla.pragmatach.framework.annotation.Controller;
007    import com.khubla.pragmatach.framework.api.PragmatachException;
008    import com.khubla.pragmatach.framework.api.Response;
009    import com.khubla.pragmatach.framework.controller.impl.template.SimpleTemplateController;
010    
011    /**
012     * @author tome
013     */
014    @Controller(name = "pragmatachHttpErrorController")
015    public class HttpErrorController extends SimpleTemplateController {
016       /**
017        * Exception
018        */
019       private final Exception exception;
020    
021       /**
022        * ctor
023        */
024       public HttpErrorController(Exception e) {
025          exception = e;
026       }
027    
028       public Response render() throws PragmatachException {
029          try {
030             final Map<String, String> parameters = new HashMap<String, String>();
031             parameters.put("message", exception.getMessage());
032             final String trace = PragmatachException.getExceptionTrace(exception);
033             parameters.put("trace", trace);
034             return template("system/error.html", parameters);
035          } catch (final Exception e) {
036             throw new PragmatachException("Exception in render", e);
037          }
038       }
039    }