Skip to content

Commit

Permalink
refactor(exceptions): move DebugError, ParameterError, and ParserErro…
Browse files Browse the repository at this point in the history
…r to separate module
  • Loading branch information
gnikit committed May 7, 2024
1 parent 8b0b6d9 commit af071de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
11 changes: 2 additions & 9 deletions fortls/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@

import json5

from .exceptions import DebugError, ParameterError, ParserError
from .helper_functions import only_dirs, resolve_globs
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
from .langserver import LangServer
from .parsers.internal.parser import FortranFile, ParserError


class DebugError(Exception):
"""Base class for debug CLI."""


class ParameterError(DebugError):
"""Exception raised for errors in the parameters."""
from .parsers.internal.parser import FortranFile


def is_debug_mode(args):
Expand Down
17 changes: 17 additions & 0 deletions fortls/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations


class DebugError(Exception):
"""Base class for debug CLI."""


class ParameterError(DebugError):
"""Exception raised for errors in the parameters."""


class ParserError(Exception):
"""Parser base class exception"""


class FortranFileNotFoundError(ParserError, FileNotFoundError):
"""File not found"""
9 changes: 1 addition & 8 deletions fortls/parsers/internal/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Severity,
log,
)
from fortls.exceptions import FortranFileNotFoundError
from fortls.ftypes import (
ClassInfo,
FunSig,
Expand Down Expand Up @@ -2302,11 +2303,3 @@ def find_file_in_directories(directories: Iterable[str], filename: str) -> str:
line = line_new
output_file.append(line)
return output_file, pp_skips, pp_defines, defs_tmp


class ParserError(Exception):
"""Parser base class exception"""


class FortranFileNotFoundError(ParserError, FileNotFoundError):
"""File not found"""

0 comments on commit af071de

Please sign in to comment.