001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.ext.tag;
020
021import javax.servlet.jsp.tagext.TryCatchFinally;
022
023import lucee.commons.lang.ExceptionUtil;
024import lucee.runtime.exp.AbortException;
025import lucee.runtime.exp.PageServletException;
026
027
028/**
029 * extends Body Support Tag eith TryCatchFinally Functionality
030 */
031public abstract class BodyTagTryCatchFinallyImpl extends BodyTagImpl implements TryCatchFinally{
032
033        @Override
034        public void doCatch(Throwable t) throws Throwable {
035                ExceptionUtil.rethrowIfNecessary(t);
036                if(t instanceof PageServletException) {
037                    PageServletException pse=(PageServletException)t;
038                    t=pse.getPageException();
039                }
040            if(bodyContent!=null) {
041                        if(t instanceof AbortException){
042                                bodyContent.writeOut(bodyContent.getEnclosingWriter());
043                        }
044                        bodyContent.clearBuffer();
045                }
046                throw t;
047        }
048
049        @Override
050        public void doFinally() {
051                
052        }
053        
054}