@Override public void dispose() { throw new SilenceException("Sub-Textures cannot be disposed! Just ignore them!"); }
private static void acquireSemaphore() { try { semaphore.acquire(); } catch (InterruptedException e) { SilenceException.reThrow(e); } }
throw new SilenceException("Invalid TMX map file. The first child must be a <map> element."); SilenceException.reThrow(e);
throw new SilenceException("Cannot copy a directory into a file."); throw new SilenceException("Cannot copy a file into a directory."); throw new SilenceException("Cannot copy a non existing file."); SilenceException.reThrow(e);
@Override public void deleteOnExit() { throw new SilenceException("Cannot delete a resource upon exit."); }
throw new SilenceException("Cannot copy a directory into a file."); throw new SilenceException("Cannot copy a file into a directory."); throw new SilenceException("Cannot copy a non existing file."); SilenceException.reThrow(e);
public T pop() { synchronized (lock) { if (stack.size() == 0) try { T object = objectProvider.provide(); list.add(object); stack.push(object); } catch (Exception e) { SilenceException.reThrow(e); } return stack.pop(); } }
@Override public void deleteOnExit() { throw new SilenceException("Cannot delete an in-jar resource upon exit."); }
throw new SilenceException("Incorrect WAV file format"); SilenceException.reThrow(e);
public WavReader(DirectBuffer memory) { try { loadFromStreamImpl(new DirectBufferInputStream(memory)); } catch (IOException e) { SilenceException.reThrow(e); } }
/** * Turns the OpenAL Format integer constant into a ALFormat enum. * * @param value The integer constant * * @return The equivalent ALFormat enum */ public static ALFormat getEnum(int value) { switch (value) { case AL_FORMAT_MONO8: return MONO_8; case AL_FORMAT_MONO16: return MONO_16; case AL_FORMAT_STEREO8: return STEREO_8; case AL_FORMAT_STEREO16: return STEREO_16; } throw new SilenceException("Unknown format value: " + value); }
@Override public void savePreferences(String name, JSONObject preferences) { try { FilePath file = FilePath.getExternalFile(System.getProperty("user.home") + "\\" + name); ((LwjglFileWriter) fileWriter).writeSync(JSON.write(preferences), file, false); } catch (IOException e) { SilenceException.reThrow(e); } } }
/** * Rethrows a Throwable as a SilenceException. This method is useful if you want to turn any exception into a * runtime SilenceException. Use this method if you want to quit the game with a fatal error. * * @param throwable The thrown object containing the stacktrace. */ public static void reThrow(Throwable throwable) { // Just pass on if the throwable is of type SilenceException if (throwable instanceof SilenceException) throw (SilenceException) throwable; else throw new SilenceException(throwable.toString()); } }
private List<JarEntry> getJarEntries() throws IOException { // Get the JAR file of the resource URL url = LwjglResourceFilePath.class.getClassLoader().getResource(getPath()); if (url == null) throw new SilenceException("Error, resource doesn't exist."); String jarUrl = url.toString(); String jarPath = URLDecoder.decode(jarUrl.substring(jarUrl.indexOf('/'), jarUrl.indexOf('!')), "UTF-8"); // Now get the JarEntry for this path JarFile jarFile = new JarFile(new File(jarPath)); List<JarEntry> entries = jarFile.stream().filter(e -> e.getName().startsWith(path)) .collect(Collectors.toList()); jarFile.close(); if (entries != null) return entries; throw new IOException("Cannot find the JAR entry for " + getPath() + " in JAR file " + jarPath); }
/** * Constructs a cursor object that uses a predefined cursor defined by the operating system. * * @param standardType The type of the default cursor that this cursor object should look like. */ public Cursor(Type standardType) { handle = glfwCreateStandardCursor(standardType.getType()); if (handle == NULL) throw new SilenceException("Unable to load cursor from texture"); }
@Override public Promise<List<FilePath>> listFiles() { return new Promise<>((resolve, reject) -> isDirectory().then(isDirectory -> exists().then(exists -> { if (!isDirectory) throw new SilenceException("Cannot list files in a path which is not a directory."); if (!exists) throw new SilenceException("Cannot list files in a non existing directory."); List<FilePath> list = new ArrayList<>(); File[] children = file.listFiles(); if (children != null) for (File child : children) list.add(new AndroidExternalFilePath(path + SEPARATOR + child.getPath().replace(file.getPath(), ""))); resolve.invoke(Collections.unmodifiableList(list)); }, reject), reject)); }
@Override public Promise<List<FilePath>> listFiles() { return new Promise<>((resolve, reject) -> isDirectory().then(isDirectory -> exists().then(exists -> { if (!isDirectory) throw new SilenceException("Cannot list files in a path which is not a directory."); if (!exists) throw new SilenceException("Cannot list files in a non existing directory."); List<FilePath> list = new ArrayList<>(); File file = new File(path); File[] children = file.listFiles(); if (children != null) for (File child : children) list.add(new LwjglExternalFilePath(path + SEPARATOR + child.getPath().replace(file.getPath(), ""))); resolve.invoke(Collections.unmodifiableList(list)); }, reject), reject)); }
public void dispose() { if (disposed) throw new SilenceException("Cannot dispose an already disposed object"); instances--; renderer.dispose(); if (instances == 0) { program.dispose(); program = null; } disposed = true; } }
@Override public Promise<Void> createFile() { return new Promise<>((resolve, reject) -> isDirectory().then(isDirectory -> { if (isDirectory) throw new SilenceException("Cannot convert a directory to a file"); try { file.createNewFile(); resolve.invoke(null); } catch (IOException e) { reject.invoke(e); } })); }
@Override public Promise<List<FilePath>> listFiles() { return new Promise<>((resolve, reject) -> isDirectory().then(isDirectory -> exists().then(exists -> { try { if (!isDirectory) throw new SilenceException("Cannot list files in a path which is not a directory."); if (!exists) throw new SilenceException("Cannot list files in a non existing directory."); List<FilePath> filePaths = new ArrayList<>(); for (String s : assetManager.list(getPath())) filePaths.add(new AndroidResourceFilePath(getPath() + SEPARATOR + s)); resolve.invoke(Collections.unmodifiableList(filePaths)); } catch (IOException e) { reject.invoke(e); } }, reject), reject)); }