19.1.5. "email.errors": 例外及び欠陥クラス
******************************************

**ソースコード:** Lib/email/errors.py

======================================================================

"email.errors" モジュールでは、以下の例外クラスが定義されています:

exception email.errors.MessageError

   これは "email" パッケージが送出しうるすべての例外の基底クラスです。
   これは標準の "Exception" クラスから派生しており、追加のメソッドは定
   義されていません。

exception email.errors.MessageParseError

   This is the base class for exceptions raised by the "Parser" class.
   It is derived from "MessageError".  This class is also used
   internally by the parser used by "headerregistry".

exception email.errors.HeaderParseError

   Raised under some error conditions when parsing the **RFC 5322**
   headers of a message, this class is derived from
   "MessageParseError".  The "set_boundary()" method will raise this
   error if the content type is unknown when the method is called.
   "Header" may raise this error for certain base64 decoding errors,
   and when an attempt is made to create a header that appears to
   contain an embedded header (that is, there is what is supposed to
   be a continuation line that has no leading whitespace and looks
   like a header).

exception email.errors.BoundaryError

   Deprecated and no longer used.

exception email.errors.MultipartConversionError

   この例外は、 "Message" オブジェクトに "add_payload()" メソッドでペ
   イロードを追加したが、そのペイロードがすでにスカラー値で、メッセー
   ジの *Content-Type* メインタイプが *multipart* でないか見付からない
   場合に送出されます。 "MultipartConversionError" は "MessageError"
   と組み込みの "TypeError" を多重継承しています。

   "Message.add_payload()" は非推奨なので、実際のところこの例外が送出
   されることはほとんどありません。 しかしながら、 "attach()" メソッド
   を "MIMENonMultipart" から派生したインスタンス (たとえば
   "MIMEImage") に対して呼んだ場合にも送出されることがあります。

Here is the list of the defects that the "FeedParser" can find while
parsing messages.  Note that the defects are added to the message
where the problem was found, so for example, if a message nested
inside a *multipart/alternative* had a malformed header, that nested
message object would have a defect, but the containing messages would
not.

All defect classes are subclassed from "email.errors.MessageDefect".

* "NoBoundaryInMultipartDefect" -- メッセージが multipart だと宣言され
  ているのに、 *boundary* パラメータがありません。

* "StartBoundaryNotFoundDefect" -- *Content-Type* ヘッダで宣言された開
  始境界がありません。

* "CloseBoundaryNotFoundDefect" -- 開始境界はあるが対応する終了境界が
  ありません。

  バージョン 3.3 で追加.

* "FirstHeaderLineIsContinuationDefect" -- メッセージの最初のヘッダ行
  が継続行です。

* "MisplacedEnvelopeHeaderDefect" -- ヘッダブロックの途中に "Unix
  From" ヘッダがあります。

* "MissingHeaderBodySeparatorDefect" - 先頭に空白はないが ':' がないヘ
  ッダの解析中に行が見付かりました。その行を本体の最初の行とみなして解
  析を続けます。

  バージョン 3.3 で追加.

* "MalformedHeaderDefect" -- ヘッダにコロンがありません、あるいはそれ
  以外の不正な形式です。

  バージョン 3.3 で非推奨: この欠陥が使われていないPythonバージョンが
  いくつかあります。

* "MultipartInvariantViolationDefect" -- メッセージが *multipart* だと
  宣言されているのに、サブパートが存在しません。 メッセージがこの欠陥
  を持つ場合、内容の型が *multipart* と宣言されていても
  "is_multipart()" メソッドは偽を返すことがあるので注意してください。

* "InvalidBase64PaddingDefect" -- When decoding a block of base64
  encoded bytes, the padding was not correct.  Enough padding is added
  to perform the decode, but the resulting decoded bytes may be
  invalid.

* "InvalidBase64CharactersDefect" -- When decoding a block of base64
  encoded bytes, characters outside the base64 alphabet were
  encountered. The characters are ignored, but the resulting decoded
  bytes may be invalid.

* "InvalidBase64LengthDefect" -- When decoding a block of base64
  encoded bytes, the number of non-padding base64 characters was
  invalid (1 more than a multiple of 4).  The encoded block was kept
  as-is.
