exceptions.py
Purpose
exceptions.py defines every custom exception class used across the pipeline. All of them are trivial subclasses. The file helps give more information on the expected thing was missing, rather than a generic, ambiguous Exception or KeyError.
The most important categories for writing new code
1. Metadata field extraction exceptions
Raised by the getter functions in common/metadata.py when a specific CrossRef field is missing from an article's or journal's metadata ( e.g. AuthorNameNotFound, LicenseInfoNotFound, ArticleTitleNotFound, ArticlePublicationYearNotFound, JournalVolumeNotFound, ArticleDoiNotFound, and similar).
Why this matters for a new module: if extracting a CrossRef field (rather than reading the raw JSON directly). The convention is one exception class per distinct field, named <WhatIsMissing>NotFound.
2. Workflow control exceptions
These are about the state of the pipeline itself
PreviousModuleNotFoundException— Raised byutils.get_previous_module_latest()when no folder exists yet for the module that the new module is supposed to follow. Every module's per-article loop wraps this call in atry/except exceptions.PreviousModuleNotFoundException:and skips the article (continue) when it's raised — this is the standard way an article that "hasn't reached this stage of the pipeline yet" gets silently skipped rather than crashing the run. While new module :
try:
latest_previous_module = utils.get_previous_module_latest(previous_module, article_dir)
except exceptions.PreviousModuleNotFoundException:
logger.info(f"Previous module {previous_module} not found, skipping")
continue
-
MaxRetryExceededException— raised when an API retry loop exhausts its attempts. -
ISSNNotFoundException— signals that a given ISSN couldn't be resolved to a journal.
3. File-related exceptions
BagNotFoundException— an expected BagIt archive is missing.TorFileNotFoundError— the only exception here that subclassesFileNotFoundError.