Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow MS guidelines for custom exception types. #826

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions Source/Exceptions/SvgException.cs
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) { }

protected 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) { }

protected SvgIDWrongFormatException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
}
17 changes: 14 additions & 3 deletions Source/Exceptions/SvgGdiPlusCannotBeLoadedException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
using System;
using System;
using System.Runtime.Serialization;

namespace Svg
{
[Serializable]
public 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) { }

protected SvgGdiPlusCannotBeLoadedException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
}
8 changes: 2 additions & 6 deletions Source/Exceptions/SvgMemoryException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Svg.Exceptions
{
Expand All @@ -13,8 +10,7 @@ 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) { }
protected SvgMemoryException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
3 changes: 3 additions & 0 deletions doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ The release versions are NuGet releases.

## Unreleased (master)

### Enhancements
* made exceptions serializable to be able to cross AppDomain boundaries (see [#826](https://github.com/svg-net/SVG/pull/826))

### Fixes
* fixed filled polyline not displayed with stroke-width=0 (see [#785](https://github.com/svg-net/SVG/issues/785)
* fixed unimplemented filter classes issue (see [#768](https://github.com/svg-net/SVG/issues/768)
Expand Down
Loading