Exact solutions for a generalized nonlinear Schrödinger equation