Redaguoti

Bendrinti naudojant


CArchiveException Class

Represents a serialization exception condition

Syntax

class CArchiveException : public CException

Members

Public Constructors

Name Description
CArchiveException::CArchiveException Constructs a CArchiveException object.

Public Data Members

Name Description
CArchiveException::m_cause Indicates the exception cause.
CArchiveException::m_strFileName Specifies the name of the file for this exception condition.

Remarks

The CArchiveException class includes a public data member that indicates the cause of the exception.

CArchiveException objects are constructed and thrown inside CArchive member functions. You can access these objects within the scope of a CATCH expression. The cause code is independent of the operating system. For more information about exception processing, see Exception Handling (MFC).

Inheritance Hierarchy

CObject

CException

CArchiveException

Requirements

Header: afx.h

CArchiveException::CArchiveException

Constructs a CArchiveException object, storing the value of cause in the object.

CArchiveException(
    int cause = CArchiveException::none,
    LPCTSTR lpszArchiveName = NULL);

Parameters

cause
An enumerated type variable that indicates the reason for the exception. For a list of the enumerators, see the m_cause data member.

lpszArchiveName
Points to a string containing the name of the CArchive object causing the exception.

Remarks

You can create a CArchiveException object on the heap and throw it yourself or let the global function AfxThrowArchiveException handle it for you.

Do not use this constructor directly; instead, call the global function AfxThrowArchiveException.

CArchiveException::m_cause

Specifies the cause of the exception.

int m_cause;

Remarks

This data member is a public variable of type int. Its values are defined by a CArchiveException enumerated type. The enumerators and their meanings are as follows:

  • CArchiveException::none No error occurred.

  • CArchiveException::genericException Unspecified error.

  • CArchiveException::readOnly Tried to write into an archive opened for loading.

  • CArchiveException::endOfFile Reached end of file while reading an object.

  • CArchiveException::writeOnly Tried to read from an archive opened for storing.

  • CArchiveException::badIndex Invalid file format.

  • CArchiveException::badClass Tried to read an object into an object of the wrong type.

  • CArchiveException::badSchema Tried to read an object with a different version of the class.

    Note

    These CArchiveException cause enumerators are distinct from the CFileException cause enumerators.

    Note

    CArchiveException::generic is deprecated. Use genericException instead. If generic is used in an application and built with /clr, there will be syntax errors that are not easy to decipher.

CArchiveException::m_strFileName

Specifies the name of the file for this exception condition.

CString m_strFileName;

See also

CException Class
Hierarchy Chart
CArchive Class
AfxThrowArchiveException
Exception Processing