You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Ed Korthof <ed...@apache.org> on 2002/02/06 04:01:09 UTC

[PATCH] TurbineConfig.java -- better error handling

If turbine fails to initialize, it may well be unable to log the error
with the code currently in place.  This patch causes turbine to fail
back to STDERR if the attempt to log via the Log package fails.

thanks --

Ed

Re: [PATCH] TurbineConfig.java -- better error handling

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Ed Korthof <ed...@apache.org> writes:

> If turbine fails to initialize, it may well be unable to log the error
> with the code currently in place.  This patch causes turbine to fail
> back to STDERR if the attempt to log via the Log package fails.

Thanks Ed, committed.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] TurbineConfig.java -- better error handling

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Applied, thanks Ed.

Ed Korthof <ed...@apache.org> writes:

> The attached patch fixes another location where logging was failing
> because the init had failed.  Thanks to Daniel for pointing me to the
> update-jars target, which helped me build & test this... Now, when
> turbine is misconfigured, I get useful errors from STDERR, instead of
> just a null pointer exception or a NoClassDefFoundError.
>
> (In my case, it told me that Turbine's configuration pointed to a file
> which didn't exist -- we'd moved it, and hadn't caught every place where
> the old value was referenced.  Seeing the file it was looking for made
> it easy to use grep to find the old reference and fix it.)
>
> Index: Turbine.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
> retrieving revision 1.25
> diff -u -r1.25 Turbine.java
> --- Turbine.java	4 Feb 2002 17:19:26 -0000	1.25
> +++ Turbine.java	6 Feb 2002 05:08:01 -0000
> @@ -183,8 +183,8 @@
>              {
>                  // save the exception to complain loudly later :-)
>                  initFailure = e;
> -                Log.info("Turbine: init() failed: " + StringUtils.stackTrace(e));
>                  System.err.println(StringUtils.stackTrace(e));
> +                Log.info("Turbine: init() failed: " + StringUtils.stackTrace(e));
>                  return;
>              }
>              Log.info("Turbine: init() Ready to Rumble!");
> Index: TurbineConfig.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java,v
> retrieving revision 1.2
> diff -u -r1.2 TurbineConfig.java
> --- TurbineConfig.java	4 Feb 2002 17:10:16 -0000	1.2
> +++ TurbineConfig.java	6 Feb 2002 05:08:01 -0000
> @@ -178,7 +178,18 @@
>          }
>          catch (Exception e)
>          {
> -            Log.error("TurbineConfig: Initialization failed", e);
> +            // we failed to initialize.  the logger may not be set up.
> +            try
> +            {
> +                Log.error("TurbineConfig: Initialization failed", e);
> +            }
> +            catch (Exception e2)
> +            {
> +                System.err.println("unable to report initialization error: ");
> +                e.printStackTrace();
> +                System.err.println("secondary error: ");
> +                e2.printStackTrace();
> +            }
>          }
>      }
>  
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] TurbineConfig.java -- better error handling

Posted by Ed Korthof <ed...@apache.org>.
The attached patch fixes another location where logging was failing
because the init had failed.  Thanks to Daniel for pointing me to the
update-jars target, which helped me build & test this... Now, when
turbine is misconfigured, I get useful errors from STDERR, instead of
just a null pointer exception or a NoClassDefFoundError.

(In my case, it told me that Turbine's configuration pointed to a file
which didn't exist -- we'd moved it, and hadn't caught every place where
the old value was referenced.  Seeing the file it was looking for made
it easy to use grep to find the old reference and fix it.)

thanks --

Ed

On Tue, Feb 05, 2002 at 07:01:09PM -0800, Ed Korthof wrote:
> If turbine fails to initialize, it may well be unable to log the error
> with the code currently in place.  This patch causes turbine to fail
> back to STDERR if the attempt to log via the Log package fails.