CArchiveException Class

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see CArchiveException Class on docs.microsoft.com. Represents a serialization exception condition

class CArchiveException : public CException  

Public Constructors

NameDescription
CArchiveException::CArchiveExceptionConstructs a CArchiveException object.

Public Data Members

NameDescription
CArchiveException::m_causeIndicates the exception cause.
CArchiveException::m_strFileNameSpecifies the name of the file for this exception condition.

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).

CObject

CException

CArchiveException

Header: afx.h

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.

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.

    System_CAPS_ICON_note.jpg Note

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

    System_CAPS_ICON_note.jpg 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.

Specifies the name of the file for this exception condition.

CString m_strFileName;  

CException Class
Hierarchy Chart
CArchive Class
AfxThrowArchiveException
Exception Processing

Show: