List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:eu.carrade.amaury.BallsOfSteel.teams.BoSTeam.java
@ConfigurationValueHandler public static BoSTeam handleTeam(Map map) throws ConfigurationParseException { final World world = BallsOfSteel.get().getGameManager().getGameWorld(); if (!map.containsKey("name")) throw new ConfigurationParseException("Team name required", map); if (!map.containsKey("color")) throw new ConfigurationParseException("Team color required", map); if (!map.containsKey("chest")) throw new ConfigurationParseException("Team chest required", map); if (!map.containsKey("spawn")) throw new ConfigurationParseException("Team spawn required", map); final BoSTeam team = new BoSTeam(map.get("name").toString(), ConfigurationValueHandlers.handleValue(map.get("color").toString(), ChatColor.class)); team.setSpawnPoint(/*w w w . j a v a 2 s . c om*/ ConfigurationValueHandlers.handleValue(map.get("spawn"), PitchedVector.class).toLocation(world)); try { team.setChest(ConfigurationValueHandlers.handleValue(map.get("chest"), Vector.class).toLocation(world)); } catch (IllegalArgumentException e) { throw new ConfigurationParseException( "Invalid chest for the team " + team.getName() + ": " + e.getMessage(), map.get("chest").toString()); } return team; }
From source file:com.gwtquickstarter.server.Deferred.java
/** * Queue a task for background execution using the specified queue name and * the specified task options (including the specified task URL). * * <p>If the task URL is not specified in the task options, the * default task URL is used, even if a task URL is configured via the * <code>taskUrl</code> init parameter. The default task URL takes the form: * <blockquote>/*from w w w . j a v a2 s.c o m*/ * <code>/_ah/queue/<i><queue name></i></code> * </blockquote> * * <p>The following task options may be specified: * <ul> * <li><code>countdownMillis</code></li> * <li><code>etaMillis</code></li> * <li><code>taskName</code></li> * <li><code>url</code></li> * </ul> * * <p>The following task options are ignored: * <ul> * <li><code>header</code></li> * <li><code>headers</code></li> * <li><code>method</code></li> * <li><code>payload</code></li> * </ul> * * <p>The following task options will throw an {@link IllegalArgumentException} * if specified: * <ul> * <li><code>param</code></li> * </ul> * * @param task The task to be executed. * @param taskOptions The task options. * @throws QueueFailureException If an error occurs serializing the task. * @throws IllegalArgumentException If any <code>param</code> task options * are specified. * @return A {@link TaskHandle} for the queued task. */ public static TaskHandle defer(Deferrable task, String queueName, TaskOptions taskOptions) { // See issue #2461 (http://code.google.com/p/googleappengine/issues/detail?id=2461). // If this issue is ever resolved, the params should be removed from the TaskOptions. byte[] taskBytes = serialize(task); if (taskBytes.length <= maxTaskSizeBytes()) { try { return queueTask(taskBytes, queueName, taskOptions); } catch (IllegalArgumentException e) { log.warning(e.getMessage() + ": " + taskBytes.length); // task size too large, fall through } } // create a datastore entity and add its key as the task payload Entity entity = new Entity(ENTITY_KIND); entity.setProperty(TASK_PROPERTY, new Blob(taskBytes)); Key key = getDatastoreService().put(entity); log.info("put datastore key: " + key); try { return queueTask(serialize(key), queueName, taskOptions); } catch (RuntimeException e) { deleteEntity(key); // delete entity if error queuing task throw e; } }
From source file:jp.go.nict.langrid.p2pgridbasis.data.langrid.converter.ConvertUtil.java
public static void decode(DataAttributes from, Object to) throws DataConvertException { setLangridConverter();/*w w w . ja va 2 s . c o m*/ logger.debug("##### decode #####"); try { for (PropertyDescriptor descriptor : PropertyUtils.getPropertyDescriptors(to)) { logger.debug( "Name : " + descriptor.getName() + " / PropertyType : " + descriptor.getPropertyType()); Object value = from.getValue(descriptor.getName()); if (PropertyUtils.isWriteable(to, descriptor.getName()) && value != null) { //Write OK try { Converter converter = ConvertUtils.lookup(descriptor.getPropertyType()); if (!ignoreProps.contains(descriptor.getName())) { if (converter == null) { logger.error("no converter is registered : " + descriptor.getName() + " " + descriptor.getPropertyType()); } else { Object obj = converter.convert(descriptor.getPropertyType(), value); PropertyUtils.setProperty(to, descriptor.getName(), obj); } } } catch (IllegalArgumentException e) { e.printStackTrace(); logger.info(e.getMessage()); } catch (NoSuchMethodException e) { logger.info(e.getMessage()); } } else { if (value != null) { //Write NG logger.debug("isWriteable = false"); } else { //Write NG logger.debug("value = null"); } } } } catch (IllegalAccessException e) { throw new DataConvertException(e); } catch (InvocationTargetException e) { throw new DataConvertException(e); } }
From source file:com.legstar.codegen.CodeGenUtil.java
/** * Check that a directory is valid.//from ww w.j av a2 s .c om * * @param dir the directory name to check * @param create true if directory should be created when not found * @param errorDirName name to refer to if an error occurs */ public static void checkDirectory(final String dir, final boolean create, final String errorDirName) { try { checkDirectory(dir, create); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(errorDirName + ": " + e.getMessage()); } }
From source file:com.legstar.codegen.CodeGenUtil.java
/** * Check that a directory is valid.//from w w w . ja va 2s .co m * * @param fdir the directory name to check * @param create true if directory should be created when not found * @param errorDirName name to refer to if an error occurs */ public static void checkDirectory(final File fdir, final boolean create, final String errorDirName) { try { checkDirectory(fdir, create); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(errorDirName + ": " + e.getMessage()); } }
From source file:com.espertech.esper.core.EPServicesContextFactoryDefault.java
/** * Creates the database config service./*from w w w . j a va 2 s .c om*/ * @param configSnapshot is the config snapshot * @param schedulingService is the timer stuff * @param schedulingMgmtService for statement schedule management * @return database config svc */ protected static DatabaseConfigService makeDatabaseRefService(ConfigurationInformation configSnapshot, SchedulingService schedulingService, SchedulingMgmtService schedulingMgmtService) { DatabaseConfigService databaseConfigService; // Add auto-imports try { ScheduleBucket allStatementsBucket = schedulingMgmtService.allocateBucket(); databaseConfigService = new DatabaseConfigServiceImpl(configSnapshot.getDatabaseReferences(), schedulingService, allStatementsBucket); } catch (IllegalArgumentException ex) { throw new ConfigurationException("Error configuring engine: " + ex.getMessage(), ex); } return databaseConfigService; }
From source file:com.alibaba.jstorm.cluster.StormConfig.java
public static List<Object> All_CONFIGS() { List<Object> rtn = new ArrayList<Object>(); Config config = new Config(); Class<?> ConfigClass = config.getClass(); Field[] fields = ConfigClass.getFields(); for (int i = 0; i < fields.length; i++) { try {/*from w w w.j a va2s.c om*/ Object obj = fields[i].get(null); rtn.add(obj); } catch (IllegalArgumentException e) { LOG.error(e.getMessage(), e); } catch (IllegalAccessException e) { LOG.error(e.getMessage(), e); } } return rtn; }
From source file:com.microsoft.tfs.client.common.ui.framework.layout.GridDataBuilder.java
/** * Performs a copy operation on the specified {@link GridData}, returning a * new {@link GridData} instance that has all fields set to the same value * as the input {@link GridData}./*from w w w . j a va2 s.com*/ * * @param in * an input {@link GridData} (must not be <code>null</code>) * @return a copy of the input */ private static GridData copy(final GridData in) { final GridData out = new GridData(); /* * The copy is done reflectively instead of directly. The GridData class * has added lots of fields in different versions of Eclipse since 3.0 - * this is the easiest way to get compatibility with all those versions. */ /* * PERF: consider caching the final Field[] array. */ final Field[] fields = GridData.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isStatic(fields[i].getModifiers()) || Modifier.isFinal(fields[i].getModifiers())) { /* * skip static and final fields */ continue; } fields[i].setAccessible(true); try { final Object valueToCopy = fields[i].get(in); fields[i].set(out, valueToCopy); } catch (final IllegalArgumentException e) { final String messageFormat = "field [{0}]: {1}"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, fields[i].getName(), e.getMessage()); throw new RuntimeException(message, e); } catch (final IllegalAccessException e) { final String messageFormat = "field [{0}]: {1}"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, fields[i].getName(), e.getMessage()); throw new RuntimeException(message, e); } } return out; }
From source file:org.hxzon.util.db.springjdbc.NamedParameterUtils.java
/** * Convert a Map of named parameter values to a corresponding array. * @param parsedSql the parsed SQL statement * @param paramSource the source for named parameters * @param declaredParams the List of declared SqlParameter objects * (may be {@code null}). If specified, the parameter metadata will * be built into the value array in the form of SqlParameterValue objects. * @return the array of values//from w w w .ja v a 2 s . com */ public static Object[] buildValueArray(ParsedSql parsedSql, SqlParameterSource paramSource, List<SqlParameter> declaredParams) { Object[] paramArray = new Object[parsedSql.getTotalParameterCount()]; if (parsedSql.getNamedParameterCount() > 0 && parsedSql.getUnnamedParameterCount() > 0) { throw new RuntimeException("Not allowed to mix named and traditional ? placeholders. You have " + parsedSql.getNamedParameterCount() + " named parameter(s) and " + parsedSql.getUnnamedParameterCount() + " traditional placeholder(s) in statement: " + parsedSql.getOriginalSql()); } List<String> paramNames = parsedSql.getParameterNames(); for (int i = 0; i < paramNames.size(); i++) { String paramName = paramNames.get(i); try { Object value = paramSource.getValue(paramName); SqlParameter param = findParameter(declaredParams, paramName, i); paramArray[i] = (param != null ? new SqlParameterValue(param, value) : value); } catch (IllegalArgumentException ex) { throw new RuntimeException( "No value supplied for the SQL parameter '" + paramName + "': " + ex.getMessage()); } } return paramArray; }
From source file:BrowserLauncher.java
/** * Attempts to locate the default web browser on the local system. Caches results so it * only locates the browser once for each use of this class per JVM instance. * @return The browser for the system. Note that this may not be what you would consider * to be a standard web browser; instead, it's the application that gets called to * open the default web browser. In some cases, this will be a non-String object * that provides the means of calling the default browser. *//*from w w w .j a v a2s .co m*/ private static Object locateBrowser() { if (browser != null) { return browser; } switch (jvm) { case MRJ_2_0: try { Integer finderCreatorCode = (Integer) makeOSType.invoke(null, new Object[] { FINDER_CREATOR }); Object aeTarget = aeTargetConstructor.newInstance(new Object[] { finderCreatorCode }); Integer gurlType = (Integer) makeOSType.invoke(null, new Object[] { GURL_EVENT }); Object appleEvent = appleEventConstructor.newInstance( new Object[] { gurlType, gurlType, aeTarget, kAutoGenerateReturnID, kAnyTransactionID }); // Don't set browser = appleEvent because then the next time we call // locateBrowser(), we'll get the same AppleEvent, to which we'll already have // added the relevant parameter. Instead, regenerate the AppleEvent every time. // There's probably a way to do this better; if any has any ideas, please let // me know. return appleEvent; } catch (IllegalAccessException iae) { browser = null; errorMessage = iae.getMessage(); return browser; } catch (InstantiationException ie) { browser = null; errorMessage = ie.getMessage(); return browser; } catch (InvocationTargetException ite) { browser = null; errorMessage = ite.getMessage(); return browser; } case MRJ_2_1: File systemFolder; try { systemFolder = (File) findFolder.invoke(null, new Object[] { kSystemFolderType }); } catch (IllegalArgumentException iare) { browser = null; errorMessage = iare.getMessage(); return browser; } catch (IllegalAccessException iae) { browser = null; errorMessage = iae.getMessage(); return browser; } catch (InvocationTargetException ite) { browser = null; errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); return browser; } String[] systemFolderFiles = systemFolder.list(); // Avoid a FilenameFilter because that can't be stopped mid-list for (int i = 0; i < systemFolderFiles.length; i++) { try { File file = new File(systemFolder, systemFolderFiles[i]); if (!file.isFile()) { continue; } // We're looking for a file with a creator code of 'MACS' and // a type of 'FNDR'. Only requiring the type results in non-Finder // applications being picked up on certain Mac OS 9 systems, // especially German ones, and sending a GURL event to those // applications results in a logout under Multiple Users. Object fileType = getFileType.invoke(null, new Object[] { file }); if (FINDER_TYPE.equals(fileType.toString())) { Object fileCreator = getFileCreator.invoke(null, new Object[] { file }); if (FINDER_CREATOR.equals(fileCreator.toString())) { browser = file.toString(); // Actually the Finder, but that's OK return browser; } } } catch (IllegalArgumentException iare) { browser = browser; errorMessage = iare.getMessage(); return null; } catch (IllegalAccessException iae) { browser = null; errorMessage = iae.getMessage(); return browser; } catch (InvocationTargetException ite) { browser = null; errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); return browser; } } browser = null; break; case MRJ_3_0: case MRJ_3_1: browser = ""; // Return something non-null break; case WINDOWS_NT: browser = "cmd.exe"; break; case WINDOWS_9x: browser = "command.com"; break; case OTHER: default: browser = "firefox"; break; } return browser; }