patch: clean up exception formatting

Поиск
Список
Период
Сортировка
Искать

patch: clean up exception formatting

От:
Oliver Jowett <oliver@opencloud.com>
Дата:
Вложения:
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

Re: patch: clean up exception formatting

От:
Barry Lind <blind@xythos.com>
Дата:
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)


FAQ