With respect to your comment:
Blockquote "Is there a way to analyze and catch the errors in the code itself?"
Use arcpy.mapping.AnalyzeForSD(path_to_sddraft) to get a Python dictionary of your errors, warnings and messages.
Refer to this helpthe AnalyzeForSD (arcpy.mapping) help for code samples and further explanation: http://resources.arcgis.com/en/help/main/10.1/index.html#/AnalyzeForSD/00s30000006p000000/.