You cannot use the NotFoundError exception class for an error which should be of type e.g. ValueError. You should check first which exception is most appropriate for an error condition.