log certain error messages that weren’t

This commit is contained in:
Guilhem Fauré 2023-06-05 15:54:47 +02:00
parent 7fd92d7081
commit 32844f451b
2 changed files with 17 additions and 8 deletions

View File

@ -190,7 +190,7 @@ class WritableObject(SpipInterface):
def convert(self) -> None:
self._title = self.convert_field(self.titre)
if not CFG.export_drafts and self._draft:
raise NoExportDraftError(f"{self.titre} is a draft, cancelling export")
raise DontExportDraftError(f"{self.titre} is a draft, cancelling export")
# Print one or more line(s) in which special elements are stylized
def style_print(
@ -308,7 +308,7 @@ class LangNotFoundError(Exception):
pass
class NoExportDraftError(Exception):
class DontExportDraftError(Exception):
pass
@ -564,7 +564,7 @@ class RedactionalObject(WritableObject):
)
except LangNotFoundError as err:
logging.debug(err)
except NoExportDraftError as err:
except DontExportDraftError as err:
logging.debug(err)
return output
@ -682,8 +682,10 @@ class Section(RedactionalObject, NormalizedSection):
forcedlang, self._depth, self.dest_directory(), i, total
)
)
except LangNotFoundError:
pass # For now, do nothing
except LangNotFoundError as err:
logging.debug(err)
except DontExportDraftError as err:
logging.debug(err)
return output
# Perform all the write steps of this object

View File

@ -5,7 +5,12 @@ from os.path import isfile
from shutil import rmtree
from spip2md.config import CFG
from spip2md.extended_models import LangNotFoundError, RecursiveList, Section
from spip2md.extended_models import (
DontExportDraftError,
LangNotFoundError,
RecursiveList,
Section,
)
from spip2md.spip_models import DB
from spip2md.style import BOLD, esc
@ -48,8 +53,10 @@ as database user {esc(BOLD)}{CFG.db_user}{esc()}
ROOTLOG.debug(f"Begin exporting {lang} root section {i}/{nb}")
try:
output.append(s.write_all(lang, -1, CFG.output_dir, i, nb))
except LangNotFoundError:
pass # For now, do nothing
except LangNotFoundError as err:
logging.debug(err) # Log the error message
except DontExportDraftError as err: # Will happen in not CFG.export_drafts
logging.debug(err) # Log the error message
print() # Break line between level 0 sections in output
ROOTLOG.debug(f"Finished exporting {lang} root section {i}/{nb} {s._title}")
return output