Skip to content

Commit af071de

Browse files
committed
refactor(exceptions): move DebugError, ParameterError, and ParserError to separate module
1 parent 8b0b6d9 commit af071de

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

fortls/debug.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55

66
import json5
77

8+
from .exceptions import DebugError, ParameterError, ParserError
89
from .helper_functions import only_dirs, resolve_globs
910
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
1011
from .langserver import LangServer
11-
from .parsers.internal.parser import FortranFile, ParserError
12-
13-
14-
class DebugError(Exception):
15-
"""Base class for debug CLI."""
16-
17-
18-
class ParameterError(DebugError):
19-
"""Exception raised for errors in the parameters."""
12+
from .parsers.internal.parser import FortranFile
2013

2114

2215
def is_debug_mode(args):

fortls/exceptions.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import annotations
2+
3+
4+
class DebugError(Exception):
5+
"""Base class for debug CLI."""
6+
7+
8+
class ParameterError(DebugError):
9+
"""Exception raised for errors in the parameters."""
10+
11+
12+
class ParserError(Exception):
13+
"""Parser base class exception"""
14+
15+
16+
class FortranFileNotFoundError(ParserError, FileNotFoundError):
17+
"""File not found"""

fortls/parsers/internal/parser.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Severity,
2525
log,
2626
)
27+
from fortls.exceptions import FortranFileNotFoundError
2728
from fortls.ftypes import (
2829
ClassInfo,
2930
FunSig,
@@ -2302,11 +2303,3 @@ def find_file_in_directories(directories: Iterable[str], filename: str) -> str:
23022303
line = line_new
23032304
output_file.append(line)
23042305
return output_file, pp_skips, pp_defines, defs_tmp
2305-
2306-
2307-
class ParserError(Exception):
2308-
"""Parser base class exception"""
2309-
2310-
2311-
class FortranFileNotFoundError(ParserError, FileNotFoundError):
2312-
"""File not found"""

0 commit comments

Comments
 (0)