From 9020e459a19b9ba7fbb3704c14aa38d6438de954 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 30 Mar 2010 13:48:08 +0000 Subject: [PATCH] [MNG-2187] Improve error message when the pom is encoded in the wrong charset git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@929140 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/model/building/DefaultModelBuilder.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 0066dd8bdd..17e335db58 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -359,7 +359,20 @@ public class DefaultModelBuilder } catch ( IOException e ) { - problems.add( Severity.FATAL, "Non-readable POM " + modelSource.getLocation() + ": " + e.getMessage(), e ); + String msg = e.getMessage(); + if ( msg == null || msg.length() <= 0 ) + { + // NOTE: There's java.nio.charset.MalformedInputException and sun.io.MalformedInputException + if ( e.getClass().getName().endsWith( "MalformedInputException" ) ) + { + msg = "Some input bytes do not match the file encoding."; + } + else + { + msg = e.getClass().getSimpleName(); + } + } + problems.add( Severity.FATAL, "Non-readable POM " + modelSource.getLocation() + ": " + msg, e ); throw new ModelBuildingException( problems.getRootModelId(), problems.getProblems() ); }