Docunext


Read error lt IndexError string not matched

April 26th, 2010

This was an interesting error to debug! It comes from a Sinatra app traceback, but the full traceback wasn't much help, here's a little bit of it:

Read error: #<IndexError: string not matched>
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `[]='
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `handle_exception!'
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:586:in `rescue in dispatch!'
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:589:in `dispatch!'

I think it turned out to be an encoding error, but I'm not sure why this IndexError was showing up. Turns out that this bit of code doesn't cause a problem when there are no errors, but causes the IndexError when there is a problem:

@env = settings.environment

This is most likely Sinatra specific, if I change @env to @myenv, its OK. Since I don't actually need it, I've removed it altogether.

And to fix the encoding issue:

rlinks.encode('UTF-8', undef: :replace, invalid: :replace)
Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022