Skip to content

Commit a7f99ea

Browse files
Improve failure to import document class; better variable name
1 parent 344b73a commit a7f99ea

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Rubberduck.VBEEditor/SafeComWrappers/VBA/VBComponent.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,24 @@ private void ExportUserFormModule(string path)
137137
{
138138
if (line.Contains("OleObjectBlob"))
139139
{
140-
var resourceFileName = line.Trim().Split(new Char[] { '"' })[1];
140+
var binaryFileName = line.Trim().Split(new Char[] { '"' })[1];
141141
var tempName = Path.GetFileName(tempFile);
142142
var destPath = Directory.GetParent(path).FullName;
143-
if (File.Exists(Path.Combine(tempFilePath, resourceFileName)) && !destPath.Equals(tempFilePath))
143+
if (File.Exists(Path.Combine(tempFilePath, binaryFileName)) && !destPath.Equals(tempFilePath))
144144
{
145-
System.Diagnostics.Debug.WriteLine(Path.Combine(destPath, resourceFileName));
146-
if (File.Exists(Path.Combine(destPath, resourceFileName)))
145+
System.Diagnostics.Debug.WriteLine(Path.Combine(destPath, binaryFileName));
146+
if (File.Exists(Path.Combine(destPath, binaryFileName)))
147147
{
148148
try
149149
{
150-
File.Delete(Path.Combine(destPath, resourceFileName));
150+
File.Delete(Path.Combine(destPath, binaryFileName));
151151
}
152152
catch (Exception)
153153
{
154154
// Meh?
155155
}
156156
}
157-
File.Copy(Path.Combine(tempFilePath, resourceFileName), Path.Combine(destPath, resourceFileName));
157+
File.Copy(Path.Combine(tempFilePath, binaryFileName), Path.Combine(destPath, binaryFileName));
158158
}
159159
break;
160160
}

Rubberduck.VBEEditor/SafeComWrappers/VBA/VBComponents.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public void ImportSourceFile(string path)
116116
}
117117
catch
118118
{
119-
var temp = Add(ComponentType.ClassModule);
120-
temp.Name = name;
119+
throw new IndexOutOfRangeException(string.Format("Could not find document component named '{0}'. Try adding a document component with the same name and try again.", name));
121120
}
122121

123122
var component = this[name];

0 commit comments

Comments
 (0)