AVPKit
com::avpkit::core::IError Class Referenceabstract

Maps from int return codes to defined Error values. More...

#include <IError.h>

Inheritance diagram for com::avpkit::core::IError:
Collaboration diagram for com::avpkit::core::IError:

Public Types

enum  Type {
  ERROR_UNKNOWN , ERROR_IO , ERROR_NUMEXPECTED , ERROR_INVALIDDATA ,
  ERROR_NOMEM , ERROR_NOFMT , ERROR_NOTSUPPORTED , ERROR_NOENT ,
  ERROR_EOF , ERROR_RANGE , ERROR_AGAIN , ERROR_PATCHWELCOME ,
  ERROR_INTERRUPTED
}
 A set of errors that AVPKit knows about.
 
typedef enum com::avpkit::core::IError::Type Type
 A set of errors that AVPKit knows about.
 

Public Member Functions

virtual Type getType ()=0
 Get the OS-independent AVPKit type for this error. More...
 
virtual const char * getDescription ()=0
 Get a text description for this error. More...
 
virtual int32_t getErrorNumber ()=0
 Return the raw integer value that AVPKit returned and was used to create this IError. More...
 
- Public Member Functions inherited from com::avpkit::ferry::RefCounted
virtual int32_t acquire ()
 Internal Only. More...
 
virtual int32_t release ()
 Internal Only. More...
 
virtual RefCountedcopyReference ()
 Create a new Java object that refers to the same native object. More...
 
virtual int32_t getCurrentRefCount ()
 Return the current reference count on this object. More...
 
void setJavaAllocator (void *allocator)
 This method is public but not part of the standard API. More...
 
void * getJavaAllocator ()
 This method is public but not part of the standard API. More...
 

Static Public Member Functions

static IErrormake (int32_t errorNumber)
 Create a new IError object from a return value passed in from AVPKit. More...
 
static IErrormake (Type type)
 Create a new IError object from an IError.Type enum value. More...
 
static Type errorNumberToType (int32_t errorNo)
 Translate an error number to a type. More...
 
static int32_t typeToErrorNumber (Type type)
 Translate an a type to an error number. More...
 

Additional Inherited Members

- Protected Member Functions inherited from com::avpkit::ferry::RefCounted
virtual void destroy ()
 This method is called by RefCounted objects when their Ref Count reaches zero and they are about to be destroyed.
 
- Protected Attributes inherited from com::avpkit::ferry::RefCounted
AtomicIntegermRefCount
 This is the internal reference count, represented as an AtomicInteger to make sure it is thread safe.
 
void * mAllocator
 Not part of public API.
 

Detailed Description

Maps from int return codes to defined Error values.

This class is used to map from AVPKit return codes (for example on IContainer#readNextPacket(IPacket) into an enum type if the error is known and a text description.

WARNING: Do not write code that depends on the integer values returned from AVPKit; instead use the integer value to create one of these objects. That's because integer values returned from methods can have different meanings on different OS systems (for example, ERROR_AGAIN is -11 on Linux, but a different value on MacOS). This class maps the error to a os-type-safe value.

Also, do not depend on the string messages staying constant. They are for debugging purposes only. And we can't control whether or not they are localized – that's up to your OS. Sorry.

Definition at line 59 of file IError.h.

Member Function Documentation

◆ errorNumberToType()

IError::Type com::avpkit::core::IError::errorNumberToType ( int32_t  errorNo)
static

Translate an error number to a type.

Parameters
errorNoThe error returned from AVPKit
Returns
the type

Definition at line 62 of file IError.cpp.

63 {
64  return Error::errorNumberToType(errNo);
65 }

◆ getDescription()

virtual const char* com::avpkit::core::IError::getDescription ( )
pure virtual

Get a text description for this error.

The description returned will be in whatever language the underlying OS decides to use, and no, we can't support localization here if the OS hasn't already done it.

Sorry.

Returns
the description.

Implemented in com::avpkit::core::Error.

◆ getErrorNumber()

virtual int32_t com::avpkit::core::IError::getErrorNumber ( )
pure virtual

Return the raw integer value that AVPKit returned and was used to create this IError.

Note that this value can have different meanings on different operating systems. Use getType() instead for programmatic decisions.

Returns
the native error number.

Implemented in com::avpkit::core::Error.

◆ getType()

virtual Type com::avpkit::core::IError::getType ( )
pure virtual

Get the OS-independent AVPKit type for this error.

Returns
the type.

Implemented in com::avpkit::core::Error.

◆ make() [1/2]

IError * com::avpkit::core::IError::make ( int32_t  errorNumber)
static

Create a new IError object from a return value passed in from AVPKit.

Parameters
errorNumberThe error number as returned from another AVPKit call. ErrorNumber must be < 0.
Returns
a new IError, or null on error.

Definition at line 44 of file IError.cpp.

45 {
46  return Error::make(errorNumber);
47 }

◆ make() [2/2]

IError * com::avpkit::core::IError::make ( Type  type)
static

Create a new IError object from an IError.Type enum value.

Parameters
typeThe type to use for creation.
Returns
a new IError, or null on error.

Definition at line 50 of file IError.cpp.

51 {
52  return Error::make(type);
53 }

◆ typeToErrorNumber()

int32_t com::avpkit::core::IError::typeToErrorNumber ( Type  type)
static

Translate an a type to an error number.

Parameters
typeThe type
Returns
the error number

Definition at line 56 of file IError.cpp.

57 {
58  return Error::typeToErrorNumber(type);
59 }

The documentation for this class was generated from the following files: