Replace RuntimeException with error logging