Replace generic error with more specific error class