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 15, 2024
1 parent 26e742b commit 3580286
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions fortls/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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
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 @@ -2303,11 +2304,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 3580286

Please sign in to comment.