namespace Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap;
///
/// FFmpeg Exception
///
public class FfmpegException : Exception
{
///
/// Throws an if the is less than zero.
///
/// The error code.
/// The name of the function that returned the .
/// with some details (including the and the ).
public static void Try(int errorCode, string function)
{
if (errorCode < 0)
throw new FfmpegException(errorCode, function);
}
///
/// Initializes a new instance of the class with an that got returned by any ffmpeg .
///
/// The error code.
/// The name of the function that returned the .
public FfmpegException(int errorCode, string function)
: base(string.Format("{0} returned 0x{1:x8}: {2}", function, errorCode, FfmpegCalls.AvStrError(errorCode)))
{
ErrorCode = errorCode;
Function = function;
}
///
/// Initializes a new instance of the class with a describing an error that occurred by calling any ffmpeg .
///
/// The message that describes the error.
/// The name of the function that caused the error.
public FfmpegException(string message, string function)
: base(string.Format("{0} failed: {1}", message, function))
{
Function = function;
}
///
/// Initializes a new instance of the class with a message that describes the error.
///
/// The message that describes the error.
public FfmpegException(string message)
: base(message)
{
}
///
/// Gets the error code.
///
public int ErrorCode { get; private set; }
///
/// Gets the ffmpeg function which caused the error.
///
public string Function { get; private set; }
}