catch exception when searching empty string

by using flash messages