class_docstr: Override parser's default behavior of calling sys.exit().
  
  https://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code
  
  OCRmyPDF began as a CLI but eventually acquired an API. The API works inside out,
  by synthesizing a command line argument. So we subclass the standard parser with
  one that doesn't call sys.exit(). Obviously this is not the ideal way to do things
  but it works for us.
class_docstr_tok: ["Override","parser","'s","default","behavior","of","calling","sys.exit","(",")",".","https",":","\/\/stackoverflow.com\/questions\/5943249\/python-argparse-and-controlling-overriding-the-exit-status-code","OCRmyPDF","began","as","a","CLI","but","eventually","acquired","an","API",".","The","API","works","inside","out",",","by","synthesizing","a","command","line","argument",".","So","we","subclass","the","standard","parser","with","one","that","does","n't","call","sys.exit","(",")",".","Obviously","this","is","not","the","ideal","way","to","do","things","but","it","works","for","us","."]
docstr: Override the default argparse error behavior.
docstr_tok: ["Override","the","default","argparse","error","behavior","."]
code: def error(self, message):
      """Override the default argparse error behavior."""
      if not self._api_mode:
          super().error(message)
          return
      raise ValueError(message)
  
file_path: OCRmyPDF/src/ocrmypdf/cli.py
imports: from __future__ import annotations
  import argparse
  from collections.abc import Mapping
  from typing import Any, Callable, TypeVar
  from ocrmypdf._version import PROGRAM_NAME
  from ocrmypdf._version import __version__
label_desc: Use image node_id 3 for calling the ArgumentParser obj's underlying member method code with example usage: obj.error(message) without return types