Only handles incorrect master key error, not all database errors