Move initialization of $error outside switch block

fixes #3
Merge pull request #4 from PrplHaz4/patch-1

Move initialization of $error outside switch block