Saving Site as a Template Results in an Error in SharePoint 2010

 When you try to save a template in SharePoint 2010, you may receive an error at Microsoft.SharePoint.SPSolutionExporter.ExportWebToGallery where the system fails to upload the created solution in solution gallery.

 If you receive the Runtime error, first disable custom errors in application web.config. More info here..

To find the cause of problem, try running the command from Powershell by which you can trace ULS log.
$Web=Get-SPWeb http://site
$Web.SaveAsTemplate("Name","Title","Description",1)

The most common error is the duplicate feature folder in farm's 14 hive. If you have saved a site with same name anywhere in the site, try retracting the solution first. As soon as the feature folder is available again, the template will be saved/copied successfully.