replace exit by error