Re: patch: clean up exception formatting - Mailing list pgsql-jdbc

From Barry Lind
Subject Re: patch: clean up exception formatting
Date
Msg-id 3F380847.3090600@xythos.com
Whole thread Raw
In response to patch: clean up exception formatting  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Patch applied.

--Barry


Oliver Jowett wrote:
> The attached patch (against CVS HEAD) cleans up exception messages in two
> areas:
>
> 1. Remove PSQLException's override of toString() so that the exception
> classname is included in the output of toString() (i.e. the default
> Throwable behaviour). Previously a .toString() on a PSQLException produces
> something like:
>
>    "Parameter index out of range."
>
> With this patch you get the consistent-with-everything-else result:
>
>   "org.postgresql.util.PSQLException: Parameter index out of range."
>
> 2. Strip whitespace from backend-generated errors when using them as an
> exception message. Previously, you'd get tracebacks with odd blank lines:
>
>   java.sql.SQLException: ERROR:  parser: parse error at or near "null" at character 27
>
>      at org.postgresql.core.QueryExecutor.executeV2(QueryExecutor.java:286)
>      at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:104)
>
> With this patch you get the expected form:
>
>   java.sql.SQLException: ERROR:  parser: parse error at or near "null" at character 27
>      at org.postgresql.core.QueryExecutor.executeV2(QueryExecutor.java:286)
>      at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:104)
>
> -O
>
>
> ------------------------------------------------------------------------
>
> Index: src/interfaces/jdbc/org/postgresql/util/PSQLException.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/util/PSQLException.java,v
> retrieving revision 1.11
> diff -c -r1.11 PSQLException.java
> *** src/interfaces/jdbc/org/postgresql/util/PSQLException.java    14 Mar 2003 01:21:47 -0000    1.11
> --- src/interfaces/jdbc/org/postgresql/util/PSQLException.java    20 Jul 2003 04:29:16 -0000
> ***************
> *** 127,138 ****
>       {
>           return message;
>       }
> -
> -     /*
> -      * Overides Object
> -      */
> -     public String toString()
> -     {
> -         return message != null ? message : "";
> -     }
>   }
> --- 127,130 ----
> Index: src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java,v
> retrieving revision 1.22
> diff -c -r1.22 QueryExecutor.java
> *** src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java    29 May 2003 03:21:32 -0000    1.22
> --- src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java    20 Jul 2003 04:29:16 -0000
> ***************
> *** 192,198 ****
>
>               // did we get an error during this query?
>               if ( errorMessage != null )
> !                 throw new SQLException( errorMessage.toString() );
>
>
>               //if an existing result set was passed in reuse it, else
> --- 192,198 ----
>
>               // did we get an error during this query?
>               if ( errorMessage != null )
> !                 throw new SQLException( errorMessage.toString().trim() );
>
>
>               //if an existing result set was passed in reuse it, else
> ***************
> *** 283,289 ****
>
>               // did we get an error during this query?
>               if ( errorMessage != null )
> !                 throw new SQLException( errorMessage.toString() );
>
>
>               //if an existing result set was passed in reuse it, else
> --- 283,289 ----
>
>               // did we get an error during this query?
>               if ( errorMessage != null )
> !                 throw new SQLException( errorMessage.toString().trim() );
>
>
>               //if an existing result set was passed in reuse it, else
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: patch: tiny patch to correct stringbuffer size estimate
Next
From: Barry Lind
Date:
Subject: Re: patch: fix skeleton code in test README