-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow MS guidelines for custom exception types.
- make custom exception types serializable.
- Loading branch information
1 parent
ef55e3c
commit bf89bf4
Showing
4 changed files
with
51 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Svg | ||
{ | ||
[Serializable] | ||
public class SvgException : FormatException | ||
{ | ||
public SvgException(string message) : base(message) | ||
{ | ||
} | ||
public SvgException() { } | ||
public SvgException(string message) : base(message) { } | ||
public SvgException(string message, Exception inner) : base(message, inner) { } | ||
|
||
protected SvgException(SerializationInfo info, StreamingContext context) | ||
: base (info, context) { } | ||
} | ||
|
||
[Serializable] | ||
public class SvgIDException : FormatException | ||
{ | ||
public SvgIDException(string message) | ||
: base(message) | ||
{ | ||
} | ||
public SvgIDException() { } | ||
public SvgIDException(string message) : base(message) { } | ||
public SvgIDException(string message, Exception inner) : base(message, inner) { } | ||
|
||
protected SvgIDException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
|
||
[Serializable] | ||
public class SvgIDExistsException : SvgIDException | ||
{ | ||
public SvgIDExistsException(string message) | ||
: base(message) | ||
{ | ||
} | ||
public SvgIDExistsException() { } | ||
public SvgIDExistsException(string message) : base(message) { } | ||
public SvgIDExistsException(string message, Exception inner) : base(message, inner) { } | ||
|
||
private SvgIDExistsException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
|
||
[Serializable] | ||
public class SvgIDWrongFormatException : SvgIDException | ||
{ | ||
public SvgIDWrongFormatException(string message) | ||
: base(message) | ||
{ | ||
} | ||
public SvgIDWrongFormatException() { } | ||
public SvgIDWrongFormatException(string message) : base(message) { } | ||
public SvgIDWrongFormatException(string message, Exception inner) : base(message, inner) { } | ||
|
||
private SvgIDWrongFormatException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
using System; | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Svg | ||
{ | ||
public class SvgGdiPlusCannotBeLoadedException : Exception | ||
[Serializable] | ||
public sealed class SvgGdiPlusCannotBeLoadedException : Exception | ||
{ | ||
public SvgGdiPlusCannotBeLoadedException(Exception inner) : base("Cannot initialize gdi+ libraries. This is likely to be caused by running on a non-Windows OS without proper gdi+ replacement. Please refer to the documentation for more details.", inner) {} | ||
const string gdiErrorMsg = "Cannot initialize gdi+ libraries. This is likely to be caused by running on a non-Windows OS without proper gdi+ replacement. Please refer to the documentation for more details."; | ||
|
||
public SvgGdiPlusCannotBeLoadedException() : base(gdiErrorMsg) { } | ||
public SvgGdiPlusCannotBeLoadedException(string message) : base(message) { } | ||
public SvgGdiPlusCannotBeLoadedException(Exception inner) : base(gdiErrorMsg, inner) {} | ||
public SvgGdiPlusCannotBeLoadedException(string message, Exception inner) : base(message, inner) { } | ||
|
||
private SvgGdiPlusCannotBeLoadedException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
|
||
namespace Svg.Exceptions | ||
{ | ||
[Serializable] | ||
public class SvgMemoryException : Exception | ||
public sealed class SvgMemoryException : Exception | ||
{ | ||
public SvgMemoryException() { } | ||
public SvgMemoryException(string message) : base(message) { } | ||
public SvgMemoryException(string message, Exception inner) : base(message, inner) { } | ||
|
||
protected SvgMemoryException( | ||
SerializationInfo info, | ||
StreamingContext context) : base(info, context) { } | ||
private SvgMemoryException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters