Search in sources :

Example 11 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class Throw method _doStartTag.

private void _doStartTag(Object obj) throws PageException {
    if (!StringUtil.isEmpty(obj)) {
        PageException pe = toPageException(obj, null);
        if (pe != null)
            throw pe;
        CustomTypeException exception = new CustomTypeException(Caster.toString(obj), detail, errorcode, type, extendedinfo, level);
        throw exception;
    }
}
Also used : PageException(lucee.runtime.exp.PageException) CustomTypeException(lucee.runtime.exp.CustomTypeException)

Example 12 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class Trace method _doEndTag.

public void _doEndTag() throws IOException, PageException {
    PageSource ps = pageContext.getCurrentTemplatePageSource();
    // var
    String varValue = null;
    Object value = null, traceValue = null;
    if (!StringUtil.isEmpty(var)) {
        try {
            if (caller instanceof Scope)
                value = VariableInterpreter.getVariable(pageContext, var, (Scope) caller);
            else
                value = pageContext.getVariable(var);
        } catch (PageException e) {
            varValue = "(undefined)";
            follow = false;
        }
        if (follow) {
            // print.o(1);
            if (StringUtil.isEmpty(text, true))
                text = var;
            // print.o(2);
            traceValue = TraceObjectSupport.toTraceObject(pageContext.getDebugger(), value, type, category, text);
            if (caller instanceof Scope)
                VariableInterpreter.setVariable(pageContext, var, traceValue, (Scope) caller);
            else
                pageContext.setVariable(var, traceValue);
        }
        try {
            varValue = new ScriptConverter().serialize(value);
        } catch (ConverterException e) {
            if (value != null)
                varValue = "(" + Caster.toTypeName(value) + ")";
        }
    }
    DebugTrace trace = ((DebuggerImpl) pageContext.getDebugger()).addTrace(type, category, text, ps, var, varValue);
    DebugTrace[] traces = pageContext.getDebugger().getTraces(pageContext);
    String total = "(1st trace)";
    if (traces.length > 1) {
        long t = 0;
        for (int i = 0; i < traces.length; i++) {
            t += traces[i].getTime();
        }
        total = "(" + t + ")";
    }
    boolean hasCat = !StringUtil.isEmpty(trace.getCategory());
    boolean hasText = !StringUtil.isEmpty(trace.getText());
    boolean hasVar = !StringUtil.isEmpty(var);
    // inline
    if (inline) {
        lucee.runtime.format.TimeFormat tf = new lucee.runtime.format.TimeFormat(pageContext.getConfig().getLocale());
        StringBuffer sb = new StringBuffer();
        sb.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"white\">");
        sb.append("<tr>");
        // sb.append("<td><img src=\"/CFIDE/debug/images/Error_16x16.gif\" alt=\"Error type\">");
        sb.append("<td>");
        sb.append("<font color=\"orange\">");
        sb.append("<b>");
        sb.append(DebugTraceImpl.toType(trace.getType(), "INFO") + " - ");
        sb.append("[CFTRACE " + tf.format(new DateTimeImpl(pageContext.getConfig()), "hh:mm:ss:l") + "]");
        sb.append("[" + trace.getTime() + " ms " + total + "]");
        sb.append("[" + trace.getTemplate() + " @ line: " + trace.getLine() + "]");
        if (hasCat || hasText)
            sb.append(" -");
        if (hasCat)
            sb.append("  [" + trace.getCategory() + "]");
        if (hasText)
            sb.append(" <i>" + trace.getText() + "&nbsp;</i>");
        sb.append("</b>");
        sb.append("</font>");
        sb.append("</td>");
        sb.append("</tr>");
        sb.append("</table>");
        pageContext.forceWrite(sb.toString());
        if (hasVar)
            Dump.call(pageContext, value, var);
    }
    // log
    Log log = ((ConfigImpl) pageContext.getConfig()).getLog("trace");
    StringBuffer msg = new StringBuffer();
    msg.append("[" + trace.getTime() + " ms " + total + "] ");
    msg.append("[" + trace.getTemplate() + " @ line: " + trace.getLine() + "]");
    if (hasCat || hasText || hasVar)
        msg.append("- ");
    if (hasCat)
        msg.append("[" + trace.getCategory() + "] ");
    if (hasVar)
        msg.append("[" + var + "=" + varValue + "] ");
    if (hasText)
        msg.append(" " + trace.getText() + " ");
    log.log(trace.getType(), "cftrace", msg.toString());
    // abort
    if (abort)
        throw new Abort(Abort.SCOPE_REQUEST);
}
Also used : PageException(lucee.runtime.exp.PageException) ConverterException(lucee.runtime.converter.ConverterException) Log(lucee.commons.io.log.Log) DebuggerImpl(lucee.runtime.debug.DebuggerImpl) PageSource(lucee.runtime.PageSource) Abort(lucee.runtime.exp.Abort) Scope(lucee.runtime.type.scope.Scope) DebugTrace(lucee.runtime.debug.DebugTrace) ScriptConverter(lucee.runtime.converter.ScriptConverter) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 13 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class Update method doEndTag.

@Override
public int doEndTag() throws PageException {
    Object ds = DBInfo.getDatasource(pageContext, datasource);
    DataSourceManager manager = pageContext.getDataSourceManager();
    DatasourceConnection dc = ds instanceof DataSource ? manager.getConnection(pageContext, (DataSource) ds, username, password) : manager.getConnection(pageContext, Caster.toString(ds), username, password);
    try {
        Struct meta = null;
        try {
            meta = Insert.getMeta(dc, tablequalifier, tableowner, tablename);
        } catch (SQLException se) {
            meta = new StructImpl();
        }
        String[] pKeys = getPrimaryKeys(dc);
        SQL sql = createSQL(dc, pKeys, meta);
        if (sql != null) {
            lucee.runtime.type.Query query = new QueryImpl(pageContext, dc, sql, -1, -1, null, "query");
            if (pageContext.getConfig().debug()) {
                String dsn = ds instanceof DataSource ? ((DataSource) ds).getName() : Caster.toString(ds);
                boolean logdb = ((ConfigImpl) pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
                if (logdb) {
                    boolean debugUsage = DebuggerUtil.debugQueryUsage(pageContext, query);
                    pageContext.getDebugger().addQuery(debugUsage ? query : null, dsn, "", sql, query.getRecordcount(), pageContext.getCurrentPageSource(), query.getExecutionTime());
                }
            }
            // log
            Log log = pageContext.getConfig().getLog("datasource");
            if (log.getLogLevel() >= Log.LEVEL_INFO) {
                log.info("update tag", "executed [" + sql.toString().trim() + "] in " + DecimalFormat.call(pageContext, query.getExecutionTime() / 1000000D) + " ms");
            }
        }
        return EVAL_PAGE;
    } catch (PageException pe) {
        pageContext.getConfig().getLog("datasource").error("update tag", pe);
        throw pe;
    } finally {
        manager.releaseConnection(pageContext, dc);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) Log(lucee.commons.io.log.Log) DataSourceManager(lucee.runtime.db.DataSourceManager) DataSource(lucee.runtime.db.DataSource) Struct(lucee.runtime.type.Struct) SQL(lucee.runtime.db.SQL) QueryImpl(lucee.runtime.type.QueryImpl) StructImpl(lucee.runtime.type.StructImpl) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 14 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class Video method toMpeg.

private Pair toMpeg(VideoInput vi) throws PageException, IOException {
    VideoInfo info = getInfo(vi);
    if ("mpeg1video".equals(info.getVideoCodec()))
        return new Pair(vi.getResource(), toStruct(info));
    VideoOutput tmp = new VideoOutputImpl(pageContext.getConfig().getTempDirectory().getRealResource("tmp-" + new Random().nextInt() + ".mpg"));
    try {
        doActionConvert(vi, tmp, null, null, NAMECONFLICT_ERROR);
        return new Pair(tmp.getResource(), toStruct(info));
    } catch (PageException pe) {
        tmp.getResource().delete();
        throw pe;
    } catch (IOException ioe) {
        tmp.getResource().delete();
        throw ioe;
    }
}
Also used : PageException(lucee.runtime.exp.PageException) VideoOutput(lucee.runtime.video.VideoOutput) Random(java.util.Random) VideoOutputImpl(lucee.runtime.video.VideoOutputImpl) VideoInfo(lucee.runtime.video.VideoInfo) IOException(java.io.IOException)

Example 15 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class XMLCaster method writeTo.

public static void writeTo(Node node, Result res, boolean omitXMLDecl, boolean indent, String publicId, String systemId, String encoding) throws PageException {
    try {
        Transformer t = XMLUtil.getTransformerFactory().newTransformer();
        t.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
        t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDecl ? "yes" : "no");
        // optional properties
        if (!StringUtil.isEmpty(publicId, true))
            t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, publicId);
        if (!StringUtil.isEmpty(systemId, true))
            t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, systemId);
        if (!StringUtil.isEmpty(encoding, true))
            t.setOutputProperty(OutputKeys.ENCODING, encoding);
        t.transform(new DOMSource(node), res);
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Transformer(javax.xml.transform.Transformer) PageException(lucee.runtime.exp.PageException) IOException(java.io.IOException) XMLException(lucee.runtime.exp.XMLException) CasterException(lucee.runtime.exp.CasterException) ExpressionException(lucee.runtime.exp.ExpressionException)

Aggregations

PageException (lucee.runtime.exp.PageException)200 ApplicationException (lucee.runtime.exp.ApplicationException)56 IOException (java.io.IOException)54 Struct (lucee.runtime.type.Struct)49 StructImpl (lucee.runtime.type.StructImpl)37 ExpressionException (lucee.runtime.exp.ExpressionException)32 Resource (lucee.commons.io.res.Resource)30 SecurityException (lucee.runtime.exp.SecurityException)26 BundleException (org.osgi.framework.BundleException)26 MalformedURLException (java.net.MalformedURLException)25 Array (lucee.runtime.type.Array)21 Key (lucee.runtime.type.Collection.Key)17 PageRuntimeException (lucee.runtime.exp.PageRuntimeException)15 SAXException (org.xml.sax.SAXException)15 Entry (java.util.Map.Entry)14 ClassException (lucee.commons.lang.ClassException)14 DeprecatedException (lucee.runtime.exp.DeprecatedException)14 SMTPException (lucee.runtime.net.mail.SMTPException)13 ArrayImpl (lucee.runtime.type.ArrayImpl)13 Query (lucee.runtime.type.Query)13