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:demo.hw.server.HelloWorldImpl.java

@Transactional
public String sayHi(String text) {
    System.out.println("sayHi called");
    Exception e = new Exception("junk");
    e.printStackTrace();//from   w  w w .  j  a v  a  2s  .c  o  m
    return "Hello " + text;
}

From source file:br.com.s2it.snakes.services.CarService.java

public Car findByLicensePlate(String licensePlate) throws Exception {
    if (licensePlate == null || licensePlate.isEmpty()) {
        throw new Exception("null_params");
    }/*from   w ww.  j  a v  a 2 s  . c om*/
    return repository.findByLicensePlate(licensePlate);
}

From source file:com.nhpatt.dremelapp.FileEntryService.java

public JSONObject getFileEntry(long classPK) throws Exception {
    JSONObject _command = new JSONObject();

    try {//  w ww.  java 2  s .  c o  m
        JSONObject _params = new JSONObject();

        _params.put("classPK", classPK);

        _command.put("/screens-web.screensassetentry/get-file-entry", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.abiquo.abiserver.business.authentication.TokenUtils.java

/**
 * Returns an array containing each token field
 * <ul>//from  w  w w .j  a v  a2  s .  com
 * <li>[0] => The token signature.</li>
 * <li>[1] => The token user name.</li>
 * <li>[2] => The token expiration time.</li>
 * </ul>
 * 
 * @param token The token.
 * @return The token fields.
 * @throws Exception
 */
public static String[] getTokenFields(final String token) throws Exception {
    String base64Token = token;
    for (int j = 0; j < base64Token.length() % 4; j++) {
        base64Token = base64Token + "=";
    }

    if (!Base64.isArrayByteBase64(base64Token.getBytes())) {
        throw new Exception("Token is not Base64 encoded");
    }

    String decodedToken = new String(Base64.decodeBase64(base64Token.getBytes()));
    return decodedToken.split(":");
}

From source file:com.artivisi.salary.payroll.system.controller.CutiController.java

@RequestMapping(value = "cuti/{id}", method = RequestMethod.GET)
public Cuti findCutiById(@PathVariable String id) throws Exception {
    Cuti cuti = cutiService.findOne(id);
    if (cuti == null) {
        throw new Exception("Data tidak ditemukan");
    }// w w w.  ja  va 2  s . c  om
    return cutiService.findOne(id);
}

From source file:com.liferay.mobile.android.http.file.DownloadUtil.java

public static void downloadWebDAVFile(Session session, int portalVersion, String groupFriendlyURL,
        String folderPath, String fileTitle, OutputStream os, FileProgressCallback callback) throws Exception {

    Authentication auth = session.getAuthentication();

    if ((auth != null) && !(auth instanceof DigestAuthentication)) {
        throw new Exception(
                "Can't download file if authentication implementation is not " + "DigestAuthentication");
    }//  w  w w  .  j ava2s.  com

    String URL = getWebDAVFileURL(session, portalVersion, groupFriendlyURL, folderPath, fileTitle);

    download(session, os, URL, callback);
}

From source file:XmlHelper.java

/**
 * Gets the child of the specified element having the specified unique name.
 * If there are more than one children elements with the same name and
 * exception is thrown./*from  w ww  .  j a v a  2 s. c  om*/
 * 
 * @param element
 *          The parent element
 * @param tagName
 *          The name of the desired child
 * @return The named child.
 * 
 * @throws Exception
 *           Child was not found or was not unique.
 */
public static Element getUniqueChild(Element element, String tagName) throws Exception {
    Iterator goodChildren = getChildrenByTagName(element, tagName);

    if (goodChildren != null && goodChildren.hasNext()) {
        Element child = (Element) goodChildren.next();
        if (goodChildren.hasNext()) {
            throw new Exception("expected only one " + tagName + " tag");
        }
        return child;
    } else {
        throw new Exception("expected one " + tagName + " tag");
    }
}

From source file:ejava.projects.edmv.ejb.ParserTestEJB.java

public void ingest() throws Exception {
    log.info("ingest");

    InputStream is = null;/*  ww  w.  j  a v  a2s .  co m*/

    try {
        log.trace("getting input file:" + xmlFile);
        is = this.getClass().getResourceAsStream(xmlFile);
        if (is == null) {
            throw new Exception(xmlFile + " was not found");
        }

        log.trace("creating parser");
        EDmvParser parser = new EDmvParser(Dmv.class, is);

        log.trace("starting parse loop");
        List<Person> people = new ArrayList<Person>();
        Object object = null;
        do {
            object = parser.getObject("Person", "VehicleRegistration");
            if (object instanceof Person) {
                if (((Person) object).getId().contains("1000")) {
                    log.debug("here");
                }
                check((Person) object, people);
            } else if (object instanceof VehicleRegistration) {
                check((VehicleRegistration) object, people);
            } else if (object != null) {
                fail("object of unknown type:" + object);
            }
        } while (object != null);
    } finally {
        if (is != null)
            is.close();
    }
}

From source file:apiserver.services.image.controllers.filters.ImageMarbleTests.java

@Test
public void directTest() throws Exception {
    throw new Exception("Not implemented yet");
}

From source file:com.eviware.soapui.impl.wsdl.support.CompressionSupport.java

private static void checkAlg(String alg) throws Exception {
    if (!ALG_GZIP.equals(alg) && !ALG_DEFLATE.equals(alg)) {
        throw new Exception("Compression algorithm not supported: " + alg);
    }//from  w w w.j  a va2 s . c o  m
}