001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.commons.beanquery; 018 019import org.apache.juneau.commons.*; 020 021/** 022 * A server-side failure while running a valid {@link BeanQuery}: a {@code SQLException}, a connection failure, or a 023 * column accessor that throws. 024 * 025 * <p> 026 * Contrast with {@link BeanQuerySyntaxException}, which reports bad caller input (HTTP 400). This exception maps to 027 * HTTP 500. Its message is deliberately generic (for example {@code "Query execution failed for table 'person'."}); 028 * the underlying cause is attached, and engines log any SQL text instead of putting it in the message. 029 * 030 * <h5 class='section'>Example:</h5> 031 * <p class='bjava'> 032 * <jk>try</jk> (SqlBeanQuerySession<Person> <jv>session</jv> = <jv>context</jv>.getSession()) { 033 * <jk>return</jk> <jv>session</jv>.find(<jv>query</jv>); 034 * } <jk>catch</jk> (BeanQuerySyntaxException <jv>e</jv>) { 035 * <jk>throw new</jk> BadRequest(<jv>e</jv>.getMessage()); <jc>// The caller's fault.</jc> 036 * } <jk>catch</jk> (BeanQueryExecutionException <jv>e</jv>) { 037 * <jk>throw new</jk> InternalServerError(<jv>e</jv>, <js>"Search failed."</js>); <jc>// Ours.</jc> 038 * } 039 * </p> 040 * 041 * @since 10.0.0 042 */ 043public class BeanQueryExecutionException extends BasicRuntimeException { 044 045 private static final long serialVersionUID = 1L; 046 047 /** 048 * Constructor. 049 * 050 * @param cause The underlying failure. Can be <jk>null</jk>. 051 * @param message The printf-style message. 052 * @param args The message arguments. 053 */ 054 public BeanQueryExecutionException(Throwable cause, String message, Object...args) { 055 super(cause, message, args); 056 } 057}