diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala
index f6b7f0854bf22a440b4f55cb1213ffecd816da59..d2bbf196cb6ab8e4a7222154c956dfb84efbbe6a 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala
@@ -136,7 +136,7 @@ private[sql] abstract class BaseWriterContainer(
           // to tell the user to look for the actual error.
           throw new SparkException("The output file already exists but this could be due to a " +
             "failure from an earlier attempt. Look through the earlier logs or stage page for " +
-            "the first error.\n  File exists error: " + e.getLocalizedMessage, e)
+            "the first error.\n  File exists error: " + e, e)
         } else {
           throw e
         }