Author: markt
Date: Sun Mar 17 13:43:33 2013
New Revision: 1457448

URL: http://svn.apache.org/r1457448
Log:
Provide some meaningful error messages for the exceptions

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties?rev=1457448&r1=1457447&r2=1457448&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties 
Sun Mar 17 13:43:33 2013
@@ -17,5 +17,14 @@ pojoEndpointBase.onCloseFail=Failed to c
 pojoEndpointBase.onErrorFail=Failed to call onError method of POJO end point 
for POJO of type [{0}]
 pojoEndpointBase.onOpenFail=Failed to call onOpen method of POJO end point for 
POJO of type [{0}]
 pojoEndpointServer.getPojoInstanceFail=Failed to create instance of POJO of 
type [{0}]
+pojoMethodMapping.duplicateLastParam=Multiple boolean (last) parameters 
present on the method [{0}] of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.duplicateMessageParam=Multiple message parameters present on 
the method [{0}] of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.duplicatePongMessageParam=Multiple PongMessage parameters 
present on the method [{0}] of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.duplicateSessionParam=Multiple session parameters present on 
the method [{0}] of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.invalidType=Unable to coerce value [{0}] to type [{1}]. That 
type is not supported.
+pojoMethodMapping.noPayload=No payload parameter present on the method [{0}] 
of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.onErrorNoThrowable=No Throwable parameter was present on the 
method [{0}] of class [{1}] that was annotated with OnError
+pojoMethodMapping.partialPong=Invalid PongMessgae and boolean parameters 
present on the method [{0}] of class [{1}] that was annotated with OnMessage
+pojoMethodMapping.pongWithPayload=Invalid PongMessgae and Message parameters 
present on the method [{0}] of class [{1}] that was annotated with OnMessage
 pojoMessageHandlerWhole.decodeFail=Failed to decode received message with 
first matching Decoder instance
 pojoMessageHandlerWhole.decodeIoFail=IO error while decoding message
\ No newline at end of file

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java?rev=1457448&r1=1457447&r2=1457448&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java 
Sun Mar 17 13:43:33 2013
@@ -202,8 +202,9 @@ public class PojoMethodMapping {
             }
         }
         if (!foundThrowable) {
-            // TODO i18n
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(sm.getString(
+                    "pojoMethodMapping.onErrorNoThrowable",
+                    m.getName(), m.getClass().getName()));
         }
         return result;
     }
@@ -254,8 +255,8 @@ public class PojoMethodMapping {
         } else if (type.equals(short.class) || type.equals(Short.class)) {
             return Short.valueOf(value);
         } else {
-            // TODO
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(sm.getString(
+                    "pojoMethodMapping.invalidType", value, type.getName()));
         }
     }
 
@@ -298,43 +299,49 @@ public class PojoMethodMapping {
                     if (indexString == -1) {
                         indexString = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicateMessageParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else if (types[i] == boolean.class) {
                     if (indexBoolean == -1) {
                         indexBoolean = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicateLastParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else if (types[i] == ByteBuffer.class) {
                     if (indexByteBuffer == -1) {
                         indexByteBuffer = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicateMessageParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else if (types[i] == byte[].class) {
                     if (indexByteArray == -1) {
                         indexByteArray = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicateMessageParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else if (types[i] == Session.class) {
                     if (indexSession == -1) {
                         indexSession = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicateSessionParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else if (types[i] == PongMessage.class) {
                     if (indexPong == -1) {
                         indexPong = i;
                     } else {
-                        // TODO i18n
-                        throw new IllegalArgumentException();
+                        throw new IllegalArgumentException(sm.getString(
+                                "pojoMethodMapping.duplicatePongMessageParam",
+                                m.getName(), m.getClass().getName()));
                     }
                 } else {
                     for (DecoderEntry decoderEntry : decoderEntries) {
@@ -347,16 +354,18 @@ public class PojoMethodMapping {
                                 if (indexByteBuffer == -1) {
                                     indexByteBuffer = i;
                                 } else {
-                                    // TODO i18n
-                                    throw new IllegalArgumentException();
+                                    throw new 
IllegalArgumentException(sm.getString(
+                                            
"pojoMethodMapping.duplicateMessageParam",
+                                            m.getName(), 
m.getClass().getName()));
                                 }
                                 break;
                             } else {
                                 if (indexString == -1) {
                                     indexString = i;
                                 } else {
-                                    // TODO i18n
-                                    throw new IllegalArgumentException();
+                                    throw new 
IllegalArgumentException(sm.getString(
+                                            
"pojoMethodMapping.duplicateMessageParam",
+                                            m.getName(), 
m.getClass().getName()));
                                 }
                             }
                         }
@@ -369,35 +378,40 @@ public class PojoMethodMapping {
             }
             if (indexByteArray != -1) {
                 if (indexPayload != -1) {
-                    // TODO i18n
-                    throw new IllegalArgumentException();
+                    throw new IllegalArgumentException(sm.getString(
+                            "pojoMethodMapping.duplicateMessageParam",
+                            m.getName(), m.getClass().getName()));
                 } else {
                     indexPayload = indexByteArray;
                 }
             }
             if (indexByteBuffer != -1) {
                 if (indexPayload != -1) {
-                    // TODO i18n
-                    throw new IllegalArgumentException();
+                    throw new IllegalArgumentException(sm.getString(
+                            "pojoMethodMapping.duplicateMessageParam",
+                            m.getName(), m.getClass().getName()));
                 } else {
                     indexPayload = indexByteBuffer;
                 }
             }
             if (indexPong != -1) {
                 if (indexPayload != -1) {
-                    // TODO i18n
-                    throw new IllegalArgumentException();
+                    throw new IllegalArgumentException(sm.getString(
+                            "pojoMethodMapping.pongWithPayload",
+                            m.getName(), m.getClass().getName()));
                 } else {
                     indexPayload = indexPong;
                 }
             }
             if (indexPayload == -1) {
-                // TODO i18n
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException(sm.getString(
+                        "pojoMethodMapping.noPayload",
+                        m.getName(), m.getClass().getName()));
             }
             if (indexPong != -1 && indexBoolean != -1) {
-                // TODO i18n
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException(sm.getString(
+                        "pojoMethodMapping.partialPong",
+                        m.getName(), m.getClass().getName()));
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to