How to properly show the Excerpt only if it exists?

This works. You probably just had a syntax error.

function content( $limit ) {
    global $post;

    if( has_excerpt() ){
        $content = the_excerpt();
    } else {
      $content = explode( ' ', get_the_content(), $limit );
      if ( count($content) >= $limit ) {
        array_pop( $content );
        $content = implode( " ", $content );
        $content = wp_strip_all_tags( $content, true );
      } else {
        $content = implode( " ", $content );
      }

      $content = preg_replace( '/\[.+\]/','', $content );
      $content = apply_filters( 'the_content', $content ); 
      $content = str_replace( ']]>', ']]>', $content );
    }

    return $content;
}