File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1489,7 +1489,14 @@ def workspace_init(self):
14891489 pool .close ()
14901490 pool .join ()
14911491 for path , result in results .items ():
1492- result_obj = result .get ()
1492+ try :
1493+ result_obj = result .get ()
1494+ except Exception as e :
1495+ result_obj = (
1496+ "An exception has occured while initialising the workspace.\n "
1497+ f"Exception({ (type (e ))} ): { e } \n "
1498+ + f"Traceback: { traceback .format_exc ()} "
1499+ )
14931500 if isinstance (result_obj , str ):
14941501 self .post_message (
14951502 f"Initialization failed for file { path } : { result_obj } "
Original file line number Diff line number Diff line change 1+ import os
2+ import tempfile
3+
4+ import pytest
5+ from setup_tests import Path , run_request , write_rpc_request
6+
7+ from fortls .constants import Severity
8+
9+
10+ @pytest .fixture ()
11+ def setup_tmp_file ():
12+ levels = 2000
13+ fd , filename = tempfile .mkstemp (suffix = ".f90" )
14+ try :
15+ with os .fdopen (fd , "w" ) as tmp :
16+ tmp .write (
17+ "program nested_if\n "
18+ + str ("if (.true.) then\n " * levels )
19+ + str ("end if\n " * levels )
20+ + "end program nested_if"
21+ )
22+ yield filename
23+ finally :
24+ os .remove (filename )
25+
26+
27+ def test_recursion_error_handling (setup_tmp_file ):
28+ root = Path (setup_tmp_file ).parent
29+ request_string = write_rpc_request (1 , "initialize" , {"rootPath" : str (root )})
30+ errcode , results = run_request (request_string )
31+ assert errcode == 0
32+ assert results [0 ]["type" ] == Severity .error
You can’t perform that action at this time.
0 commit comments