Example usage for java.lang Exception Exception

List of usage examples for java.lang Exception Exception

Introduction

In this page you can find the example usage for java.lang Exception Exception.

Prototype

public Exception(Throwable cause) 

Source Link

Document

Constructs a new exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:cc.osint.graphd.client.handlers.ProtographClientResultHandler.java

public void onError(String err) {
    this.throwable = new Exception(err);
}

From source file:org.geomajas.gwt2.example.server.command.GetSimpleExceptionCommand.java

public void execute(EmptyCommandRequest request, CommandResponse response) throws Exception {
    throw new Exception("Server-side generated exception.");
}

From source file:Main.java

/**
 * @param rawValue/*from  w w  w  .j av  a  2 s. c o  m*/
 * @return
 * @throws Exception 
 */
public static double decodeRawValueToSingleDouble(String rawValue) throws Exception {
    String[] values = getSingleValue(rawValue);
    if ("D".equals(values[0]) || "U".equals(values[0]))
        return Double.parseDouble(values[1]);
    throw new Exception("Data type is not 'D' (double) or 'U' (units [points]), found '" + values[0] + "'");
}

From source file:ReflectionExecutor.java

/**
 * Execution of reflection with {@link ReflectionAction}.
 * //from   w  w w  .  j  av  a2s.  c o m
 * @param <T>
 * @param action
 * @return
 */
public static <T> T doSafeAction(final ReflectionAction<T> action) {
    final SecurityManager securityManager = System.getSecurityManager();
    if (securityManager == null) {
        try {
            return action.run();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    try {
        return AccessController.doPrivileged(new PrivilegedExceptionAction<T>() {

            @Override
            public T run() throws Exception {
                return action.run();
            }

        });
    } catch (PrivilegedActionException e) {
        Throwable cause = e.getCause();
        if (InvocationTargetException.class.isInstance(cause)) {
            InvocationTargetException e1 = (InvocationTargetException) cause;
            throw new Exception(e1.getTargetException());
        }
        throw new Exception(cause);
    }
}

From source file:com.hangum.tadpole.rdb.core.util.bander.cubrid.CubridExecutePlanUtils.java

/**
 * cubrid execute plan//from   www .  java  2  s  .  co  m
 * 
 * @param userDB
 * @param sql
 * @return
 * @throws Exception
 */
public static String plan(UserDBDAO userDB, String sql) throws Exception {
    if (!sql.toLowerCase().startsWith("select")) {
        logger.error("[cubrid execute plan ]" + sql);
        throw new Exception("This statment not select. please check.");
    }
    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement pstmt = null;

    try {
        Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
        conn = DriverManager.getConnection(userDB.getUrl(), userDB.getUsers(), userDB.getPasswd());
        conn.setAutoCommit(false); //     auto commit? false  .      

        sql = StringUtils.trim(sql).substring(6);
        if (logger.isDebugEnabled())
            logger.debug("[qubrid modifying query]" + sql);
        sql = "select " + RECOMPILE + sql;

        pstmt = conn.prepareStatement(sql);
        ((CUBRIDStatement) pstmt).setQueryInfo(true);
        rs = pstmt.executeQuery();

        String plan = ((CUBRIDStatement) pstmt).getQueryplan(); //  ?    .
        conn.commit();

        if (logger.isDebugEnabled())
            logger.debug("cubrid plan text : " + plan);

        return plan;

    } finally {
        if (rs != null)
            rs.close();
        if (pstmt != null)
            pstmt.close();
        if (conn != null)
            conn.close();
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.json.GetSolrIndividualsByVClass.java

@Override
protected JSONObject process() throws Exception {
    VClass vclass = null;/*from w  w w.  j  a  v a  2 s . c  om*/

    String vitroClassIdStr = vreq.getParameter("vclassId");
    if (vitroClassIdStr != null && !vitroClassIdStr.isEmpty()) {
        vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vitroClassIdStr);
        if (vclass == null) {
            log.debug("Couldn't retrieve vclass ");
            throw new Exception("Class " + vitroClassIdStr + " not found");
        }
    } else {
        log.debug("parameter vclassId URI parameter expected ");
        throw new Exception("parameter vclassId URI parameter expected ");
    }
    vreq.setAttribute("displayType", vitroClassIdStr);
    return JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), vreq, ctx);
}

From source file:com.pinterest.rocksplicator.controller.tasks.ThrowingTask.java

@Override
public void process(Context ctx) throws Exception {
    throw new Exception(getParameter().getErrorMsg());
}

From source file:GoogleAPI.java

public static void validateReferrer() throws Exception {
    if (referrer == null || referrer.length() == 0) {
        throw new Exception("[google-api-translate-java] Referrer is not set. Call setHttpReferrer().");
    }//  ww w . j  av a2  s .  c om
}

From source file:com.goldmansachs.kata2go.tools.utils.TarGz.java

public static void compress(Path sourceDirectoryPath, Path archiveFilePath) throws Exception {
    try {//from w  w w . jav a2 s .  com
        ImmutableList<String> tarArgs = Lists.immutable.of(UNIX_TAR, "cvzf",
                archiveFilePath.toFile().getAbsolutePath(), ".");
        Process process = new ProcessBuilder(tarArgs.toList()).directory(sourceDirectoryPath.toFile()).start();
        int exitCode = process.waitFor();
        if (exitCode != 0) {
            logStdout(process.getInputStream());
            logStdErr(process.getErrorStream());
            throw new Exception("Failed to compress");
        }
    } catch (Exception e) {
        throw new Exception("Failed to compress", e);
    }
}

From source file:info.extensiblecatalog.OAIToolkit.utils.ConfigUtil.java

public static PropertiesConfiguration load(String configFileName) throws Exception {
    prglog.info("[PRG] ConfigUtil::load(" + configFileName + ")");
    ClassLoader cloader = ConfigUtil.class.getClassLoader();
    URL configFile = cloader.getResource(configFileName);
    if (null == configFile) {
        File f = new File(configFileName);
        prglog.info("[PRG] load from file: " + f.getAbsolutePath());
        configFile = new URL("file", "", f.getAbsolutePath());
    }/*from   w w  w  .j  a  va 2 s.  c o  m*/
    prglog.info("config file: " + configFile.getPath());
    //System.out.println("The config file is " + configFile);
    //System.out.println("The config file name is " + configFileName);

    if (!(new File(configFile.getPath()).exists())) {
        prglog.error("[PRG] Inexistent configuration file: " + configFileName);
        throw new Exception("Inexistent configuration file: " + configFileName);
    }

    BufferedReader re = new BufferedReader(new FileReader(configFile.getPath()));
    /*        String tmpfile = "tmpfile.txt";
            // Create new file
            File temp = new File(tmpfile);
            
            boolean success = temp.createNewFile();
            if (success) {
     System.out.println("Its success");
    //File did not exist and was created
            } else {
     System.out.println("File already exists");
     //File already exists
            }
            
            
             if (!temp.exists())
    throw new IllegalArgumentException("no such file or directory: " + temp);
            
            if (!temp.canWrite())
    throw new IllegalArgumentException("Write protected: " + temp);
            
            System.out.println("Temporary file created. File is " + temp);
            //System.out.println("Temporary file created. Path is " + temp.getPath());
            
            BufferedWriter out = new BufferedWriter(new FileWriter(temp));
            while(true)
            {
    String s = re.readLine();
    //System.out.println(s);
    if(s!=null) {
        s = s.replaceAll("\\\\", "/");
        //System.out.println(s);
        out.write(s + System.getProperty("line.separator"));
        out.flush();
    }
    else
        break;
            }
            out.close();
    */
    try {
        //PropertiesConfiguration prop = new PropertiesConfiguration(temp);
        PropertiesConfiguration prop = new PropertiesConfiguration(configFile.getPath());
        prglog.info("[PRG] successful ConfigUtil::load");
        //temp.deleteOnExit();
        /*boolean dsuccess = temp.delete();
        if (!dsuccess)
        throw new IllegalArgumentException("Delete: deletion failed");*/
        return prop;
    } catch (ConfigurationException e) {
        prglog.error("[PRG] Unable to load properties from configuration file: " + configFileName + ". "
                + e.getMessage());
        throw new Exception(
                "Unable to load properties from configuration file: " + configFileName + ". " + e.getMessage());
    }
}