2 File: magickd/exception.d
3 Contains: Exception handling within the magickd package.
4 Copyright: (C) 2023 Mio
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 module magickd
.exception
;
26 import std
.string
: fromStringz
;
28 import graphicsmagick_c
.magick
.error
: ExceptionInfo
;
31 /// Base exception class encompassing all MagickD exceptions.
34 /// See_Also: MagickAPIException
36 class MagickException
: Exception
41 /// Construct an exception
43 public this(string msg
)
50 /// Encapsulates a GraphicsMagick ExceptionInfo structure.
52 /// Used whenever a MagickWand/PixelWand/DrawingWand throw an
53 /// exception in the C API.
57 class MagickAPIException
: MagickException
62 /// Descibes the exception that has occurred.
64 private string m_description
;
67 /// Reason for the exception being thrown.
69 private string m_reason
;
72 /// Severity of the exception
74 private int m_severity
;
77 /// Construct an API exception
80 /// exception = The ExceptionInfo structure from GraphicsMagick.
82 this(ref ExceptionInfo exception
)
84 m_severity
= exception
.severity
;
85 m_reason
= fromStringz(exception
.reason
).dup
;
86 m_description
= fromStringz(exception
.description
).dup
;
91 /// Descibes the exception that has occurred.
93 @property public string
description() const
99 /// Reason for the exception being thrown.
101 @property public string
reason() const
107 /// Severity of the exception
109 @property public int severity() const
115 /// Descibes the exception that has occurred.
117 public string
getDescription() const
119 return m_description
;
123 /// Reason for the exception being thrown.
125 public string
getReason() const
131 /// Severity of the exception
133 public int getSeverity() const