[ditz-talk] PATCH: ditz init crashes when it can't find .ditz/ditz_plugins?

Nolan Darilek nolan at thewordnerd.info
Mon Dec 29 10:47:37 EST 2008


Seems to me like it'd make more sense to catch and rescue that exception 
directly in load_plugins. IMHO, it shouldn't be an API client's job to 
say "don't fail if there are no plugins," the API should gracefully 
handle cases where none exist. And if someone embeds Ditz into, say, a 
project-tracking app, they'll have to duplicate that same logic otherwise.

On 12/29/2008 09:33 AM, Matthew Wilson wrote:
> I'm running ditz directly from my git clone, which is up to date
> through Dec 22nd.
>
> Here's the crash:
>
> $ ditz --version
> ditz 0.5
>
> $ mkdir scratch
>
> $ cd scratch/
>
> $ ditz -v init
> # loading plugins from ./.ditz-plugins
> /usr/lib/ruby/1.8/yaml.rb:143:in `initialize': No such file or
> directory - ./.ditz-plugins (Errno::ENOENT)
> 	from /usr/lib/ruby/1.8/yaml.rb:143:in `open'
> 	from /usr/lib/ruby/1.8/yaml.rb:143:in `load_file'
> 	from /home/matt/checkouts/ditz/lib/ditz.rb:55:in `load_plugins'
> 	from /home/matt/checkouts/ditz/bin/ditz:92
>
>
> And here's my patch:
>
> > From c5ff06b70c73a1bb3d1f06017e9f5c85e82675af Mon Sep 17 00:00:00 2001
> From: W. Matthew Wilson<matt at tplus1.com>
> Date: Mon, 29 Dec 2008 10:30:42 -0500
> Subject: [PATCH] Don't blow up if no .ditz/ditz-plugins dir exists
>
> ---
>   bin/ditz |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/bin/ditz b/bin/ditz
> index 04bc7a6..81a5f4c 100755
> --- a/bin/ditz
> +++ b/bin/ditz
> @@ -89,7 +89,9 @@ if $opts[:list_hooks]
>   end
>
>   begin
> -  Ditz::load_plugins $opts[:plugins_file]
> +  if File.exists? $opts[:plugins_file]
> +      Ditz::load_plugins $opts[:plugins_file]
> +  end
>   rescue LoadError =>  e
>     Ditz::debug "can't load plugins file: #{e.message}"
>   end
>    



More information about the ditz-talk mailing list