public static MagickException CreateException(IntPtr exception) { var severity = (ExceptionSeverity)NativeMagickExceptionHelper.Severity(exception); var message = NativeMagickExceptionHelper.Message(exception); var description = NativeMagickExceptionHelper.Description(exception); if (!string.IsNullOrEmpty(description)) { message += " (" + description + ")"; } if (message is null || message.Length == 0) { message = string.Empty; } var result = Create(severity, message); var relatedExceptions = CreateRelatedExceptions(exception); if (relatedExceptions != null) { result.SetRelatedException(relatedExceptions); } return(result); }
public static MagickException?Create(IntPtr exception) { if (exception == IntPtr.Zero) { return(null); } var magickException = CreateException(exception); NativeMagickExceptionHelper.Dispose(exception); return(magickException); }
private static List <MagickException>?CreateRelatedExceptions(IntPtr exception) { var nestedCount = NativeMagickExceptionHelper.RelatedCount(exception); if (nestedCount == 0) { return(null); } var result = new List <MagickException>(); for (var i = 0; i < nestedCount; i++) { var nested = NativeMagickExceptionHelper.Related(exception, i); result.Add(CreateException(nested)); } return(result); }
private static List <MagickException> CreateRelatedExceptions(IntPtr exception) { List <MagickException> result = new List <MagickException>(); int nestedCount = NativeMagickExceptionHelper.RelatedCount(exception); if (nestedCount == 0) { return(result); } for (int i = 0; i < nestedCount; i++) { IntPtr nested = NativeMagickExceptionHelper.Related(exception, i); result.Add(CreateException(nested)); } return(result); }
public static MagickException CreateException(IntPtr exception) { ExceptionSeverity severity = (ExceptionSeverity)NativeMagickExceptionHelper.Severity(exception); string message = NativeMagickExceptionHelper.Message(exception); string description = NativeMagickExceptionHelper.Description(exception); if (!string.IsNullOrEmpty(description)) { message += " (" + description + ")"; } List <MagickException> innerExceptions = CreateRelatedExceptions(exception); MagickException result = Create(severity, message); result.SetRelatedException(innerExceptions); return(result); }