示例#1
0
 /**
  * Generate an exception message
  *
  * @param aException The Exception object
  * @return A representation of the exception which is appropriate for the client type
  */
 public String generateExceptionMessage(Exception aException) {
   StringBuffer retVal = new StringBuffer("<?xml version=\"1.0\"?>\n");
   retVal.append(
       "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
   retVal.append("<wml>\n");
   retVal.append("<card><p>\n");
   retVal.append("[HTTPEventTranslator Error (");
   retVal.append(aException.getClass().toString());
   retVal.append(")]\n");
   retVal.append("</p></card>\n");
   retVal.append("</wml>");
   return retVal.toString();
 }
示例#2
0
文件: JSComm.java 项目: tmbx/kas
 // Call a javascript function. Valid arguments can null, string and numbers.
 public void func_call(String func, Object... args) {
   try {
     _func_call(func, Arrays.asList(args));
   } catch (Exception e) {
     if (func != this.js_debug_func) {
       // Send debug information about the missed call.
       this.debug(
           1,
           "jscomm",
           "func_call() exception: '" + e.getClass().toString() + ": '" + e.getMessage() + "'");
     } else {
       // Avoid loop...
       System.out.println(
           "func_call() debug exception: '"
               + e.getClass().toString()
               + ": '"
               + e.getMessage()
               + "'");
     }
     e.printStackTrace();
   }
 }
 private InputStream getResourceStream(final File file, final String resourceName) {
   try {
     JarFile jarFile = this.jarFiles.get(file);
     if (jarFile == null && file.isDirectory()) {
       final File resource = new File(file, resourceName);
       if (resource.exists()) {
         return new FileInputStream(resource);
       }
     } else {
       if (jarFile == null) {
         if (!file.exists()) {
           return null;
         }
         jarFile = new JarFile(file);
         this.jarFiles.put(file, jarFile);
         jarFile = this.jarFiles.get(file);
       }
       final JarEntry entry = jarFile.getJarEntry(resourceName);
       if (entry != null) {
         return jarFile.getInputStream(entry);
       }
     }
   } catch (Exception e) {
     this.log(
         "Ignoring Exception "
             + e.getClass().getName()
             + ": "
             + e.getMessage()
             + " reading resource "
             + resourceName
             + " from "
             + file,
         3);
   }
   return null;
 }