Package com.cedarsolutions.exception

Examples of com.cedarsolutions.exception.CedarRuntimeException


                }
            }

            return classes;
        } catch (ClassNotFoundException e) {
            throw new CedarRuntimeException("Class was not found: " + e.getMessage(), e);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to parse input entities file: " + e.getMessage(), e);
        }
    }
View Full Code Here


                when(entities.getInputStream()).thenReturn(inputStream);
            }

            return entities;
        } catch (IOException e) {
            throw new CedarRuntimeException("Error creating Resource: " + e.getMessage(), e);
        }
    }
View Full Code Here

        // Just make sure this doesn't blow up
        Exception exception = new Exception("Hello", cause);
        ExceptionUtils.addExceptionContext(exception, 1);

        // Just make sure this doesn't blow up
        CedarRuntimeException cedar = new CedarRuntimeException("Hello", cause);
        assertNull(cedar.getContext());
        ExceptionUtils.addExceptionContext(cedar, 1);
        assertNotNull(cedar.getContext());
    }
View Full Code Here

    /** Test generateStackTrace(). */
    // Just spot-check, since it's hard to confirm the exact output
    @Test public void testGenerateStackTrace() {
        assertEquals(null, GwtExceptionUtils.generateStackTrace(null));

        CedarRuntimeException e = new CedarRuntimeException();
        assertNotNull(GwtExceptionUtils.generateStackTrace(e));

        e.setContext(new ExceptionContext());
        assertNotNull(GwtExceptionUtils.generateStackTrace(e));

        e.getContext().setStackTrace("X");
        assertEquals("X", GwtExceptionUtils.generateStackTrace(e));

        assertNotNull(GwtExceptionUtils.generateStackTrace(new Exception("whatever")));
        assertNotNull(GwtExceptionUtils.generateStackTrace(new Exception("whatever", new Exception("cause"))));
    }
View Full Code Here

            File sourceFile = new File(sourceFilePath);
            String targetFilePath = join(targetDirPath, sourceFile.getName());
            File targetFile = new File(targetFilePath);
            copyFile(sourceFile, targetFile);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to copy directory: " + e.getMessage(), e);
        }
    }
View Full Code Here

            sourceChannel = new FileInputStream(sourceFile).getChannel();
            targetChannel = new FileOutputStream(targetFile).getChannel();
            targetChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to copy file: " + e.getMessage(), e);
        } finally {
            close(sourceChannel);
            close(targetChannel);
        }
    }
View Full Code Here

     */
    public static void createFile(String filePath) {
        try {
            new File(filePath).createNewFile();
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to create file: " + e.getMessage(), e);
        }
    }
View Full Code Here

     */
    public static void removeFile(String filePath) {
        File file = new File(filePath);
        if (file.exists()) {
            if (!file.delete()) {
                throw new CedarRuntimeException("Failed to remove file.");
            } else if (fileExists(filePath)) {
                throw new CedarRuntimeException("Failed to remove file.");
            }
        }
    }
View Full Code Here

     * @throws CedarRuntimeException If there is a problem with the filesystem operation.
     */
    public static void createDir(String dirPath) {
        File dirFile = new File(dirPath);
        if (!dirFile.mkdirs() && !dirFile.exists()) {
            throw new CedarRuntimeException("Failed to create directory " + dirPath + ".");
        }
    }
View Full Code Here

    public static void removeDir(String dirPath, boolean recursive) {
        File dirFile = new File(dirPath);
        if (!recursive) {
            if (dirFile.exists()) {
                if (!dirFile.delete()) {
                    throw new CedarRuntimeException("Failed to remove directory.");
                } else if (dirExists(dirPath)) {
                    throw new CedarRuntimeException("Failed to remove directory.");
                }
            }
        } else {
            removeDirRecursive(dirFile);
            if (dirExists(dirPath)) {
                throw new CedarRuntimeException("Failed to remove directory.");
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.exception.CedarRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.