Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.

Commit b90e06f

Browse files
committed
handle when file does not exist before opening it as a document
1 parent 31bc940 commit b90e06f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pugdebug/pugdebug.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
__author__ = "robertbasic"
1111

12+
import os
13+
1214
from PyQt5.QtCore import QObject
1315
from PyQt5.QtWidgets import QErrorMessage
1416

@@ -201,10 +203,22 @@ def open_document(self, path, map_paths=True):
201203
tab.
202204
203205
If the document is already open, focus the tab with that document.
206+
207+
If the path of the document should be mapped, and the file can't
208+
be found after mapping, show an error message and stop the debugging
209+
session.
204210
"""
205211

206212
path = self.__get_path_mapped_to_local(path, map_paths)
207213

214+
if path is False:
215+
self.handle_error(
216+
"File does not exist after mapping. "
217+
"Is the path map correct?"
218+
)
219+
self.stop_debug()
220+
return
221+
208222
if not self.documents.is_document_open(path):
209223
document_model = self.documents.open_document(path)
210224

@@ -637,6 +651,9 @@ def __get_path_mapped_to_local(self, path, map_paths=True):
637651
path = path[len(path_map):]
638652
path = "%s%s" % (self.file_browser.model().rootPath(), path)
639653

654+
if not os.path.isfile(path):
655+
return False
656+
640657
return path
641658

642659
def __get_path_mapped_to_remote(self, path):

0 commit comments

Comments
 (0)