-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFFmpegException.cs
52 lines (46 loc) · 1.8 KB
/
FFmpegException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace FFmpeg.AutoGen.Toolkit
{
using System;
using FFmpeg.AutoGen.Toolkit.Helpers;
/// <summary>
/// Represents an exception thrown when FFMpeg method call returns an error code.
/// </summary>
[Serializable]
public class FFmpegException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="FFmpegException"/> class.
/// </summary>
public FFmpegException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="FFmpegException"/> class using a message and a error code.
/// </summary>
/// <param name="message">The exception message.</param>
public FFmpegException(string message)
: base(message)
=> ErrorMessage = string.Empty;
/// <summary>
/// Initializes a new instance of the <see cref="FFmpegException"/> class using a message and a error code.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="errorCode">The error code returned by the FFmpeg method.</param>
public FFmpegException(string message, int errorCode)
: base(CreateMessage(message, errorCode))
{
ErrorCode = errorCode;
ErrorMessage = StringConverter.DecodeMessage(errorCode);
}
/// <summary>
/// Gets the error code returned by the FFmpeg method.
/// </summary>
public int? ErrorCode { get; }
/// <summary>
/// Gets the message text decoded from error code.
/// </summary>
public string ErrorMessage { get; }
private static string CreateMessage(string msg, int errCode)
=> $"{msg} Error code: {errCode} : {StringConverter.DecodeMessage(errCode)}";
}
}