[DOXIA-522] Make snippet macro less permissive of issues
Use ignoreDownloadError, setting default to true for backwards compatibility
Simplified code from patch

git-svn-id: https://svn.apache.org/repos/asf/maven/doxia/doxia/trunk@1745090 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
index 0f004dd..ae85ca8 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
@@ -69,7 +69,7 @@
     /**
      * in case of Exception during snippet download error will ignored and empty content returned.
      */
-    private boolean ignoreDownloadError;
+    private boolean ignoreDownloadError = true;
 
     /**
      * {@inheritDoc}
@@ -207,13 +207,18 @@
             }
             catch ( IOException e )
             {
-                getLog().debug( "IOException which reading " + url + ": " + e );
-                result = new StringBuffer( "Error during retrieving content skip as ignoreDownloadError activated." );
+                if ( ignoreDownloadError )
+                {
+                    getLog().debug( "IOException which reading " + url + ": " + e );
+                    result =
+                        new StringBuffer( "Error during retrieving content skip as ignoreDownloadError activated." );
+                }
+                else
+                {
+                    throw e;
+                }
             }
-
-
         }
-
         return result;
     }
 
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetReader.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetReader.java
index 51a7456..4ae468a 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetReader.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetReader.java
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.regex.Pattern;
 
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.IOUtil;
 
 /**
@@ -149,9 +150,12 @@
         {
             boolean capture = false;
             String line;
+            boolean foundStart = false;
+            boolean foundEnd = false;
+            boolean hasSnippetId = StringUtils.isNotEmpty( snippetId );
             while ( ( line = reader.readLine() ) != null )
             {
-                if ( snippetId == null || "".equals( snippetId.trim() ) )
+                if ( !hasSnippetId )
                 {
                     lines.add( line );
                 }
@@ -160,9 +164,11 @@
                     if ( isStart( snippetId, line ) )
                     {
                         capture = true;
+                        foundStart = true;
                     }
                     else if ( isEnd( snippetId, line ) )
                     {
+                        foundEnd = true;
                         break;
                     }
                     else if ( capture )
@@ -171,6 +177,15 @@
                     }
                 }
             }
+
+            if ( hasSnippetId && !foundStart )
+            {
+                throw new IOException( "Failed to find START of snippet " + snippetId + " in file at URL: " + source );
+            }
+            if ( hasSnippetId && !foundEnd )
+            {
+                throw new IOException( "Failed to find END of snippet " + snippetId + " in file at URL: " + source );
+            }
         }
         finally
         {
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
index 861bcb1..b89d81d 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
@@ -19,6 +19,11 @@
  * under the License.
  */
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import org.apache.maven.doxia.macro.MacroExecutionException;
 import org.apache.maven.doxia.macro.MacroRequest;
 import org.apache.maven.doxia.sink.impl.SinkEventElement;
@@ -27,11 +32,6 @@
 import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
 /**
  * Test snippet macro.
  *
@@ -120,6 +120,21 @@
 
         // no need to verify the absence of the first and second snippets if tests above were successful
         Assert.assertThat( snippet, CoreMatchers.containsString( "Этот сниппет в формате Unicode (UTF-8)" ) );
+        
+        // again
+        // Shouldn't work because no snippet called "first" exists, only "firstId"
+        macroParameters.put( "id", "first" );
+        macroParameters.put( "verbatim", "" );
+        macroParameters.put( "ignoreDownloadError", "false" );
+        try
+        {
+            executeSnippetMacro( macroParameters );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // good
+        }
     }
 
     public void testIgnoreDownloadError()
diff --git a/pom.xml b/pom.xml
index c199bb7..40f9a67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,7 @@
 
   <contributors>
     <contributor>
-      <name>Valters Vingolds</name>
+      <name>James Agnew</name>
     </contributor>
     <contributor>
       <name>Manuel Blechschmidt</name>
@@ -49,6 +49,9 @@
     <contributor>
       <name>Masatake Iwasaki</name>
     </contributor>
+    <contributor>
+      <name>Valters Vingolds</name>
+    </contributor>
   </contributors>
 
   <prerequisites>