Skip to content

Commit

Permalink
share common base class for exceptions (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored and sebastienros committed Oct 27, 2019
1 parent 3464344 commit a8d19f3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Jint/Runtime/JavaScriptException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Jint.Runtime
{
public class JavaScriptException : Exception
public class JavaScriptException : JintException
{
private string _callStack;

Expand Down
28 changes: 28 additions & 0 deletions Jint/Runtime/JintException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Runtime.Serialization;

namespace Jint.Runtime
{
/// <summary>
/// Base class for exceptions thrown by Jint.
/// </summary>
[Serializable]
public abstract class JintException : Exception
{
protected JintException()
{
}

protected JintException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

protected JintException(string message) : base(message)
{
}

protected JintException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
6 changes: 2 additions & 4 deletions Jint/Runtime/MemoryLimitExceededException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;

namespace Jint.Runtime
namespace Jint.Runtime
{
public class MemoryLimitExceededException : Exception
public class MemoryLimitExceededException : JintException
{
public MemoryLimitExceededException() : base()
{
Expand Down
6 changes: 2 additions & 4 deletions Jint/Runtime/RangeErrorException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;

namespace Jint.Runtime
namespace Jint.Runtime
{
/// <summary>
/// Workaround for situation where engine is not easily accessible.
/// </summary>
internal sealed class RangeErrorException : Exception
internal sealed class RangeErrorException : JintException
{
public RangeErrorException(string message) : base(message)
{
Expand Down
6 changes: 2 additions & 4 deletions Jint/Runtime/RecursionDepthOverflowException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using Jint.Runtime.CallStack;

namespace Jint.Runtime
{
using Jint.Runtime.CallStack;

public class RecursionDepthOverflowException : Exception
public class RecursionDepthOverflowException : JintException
{
public string CallChain { get; private set; }

Expand Down
6 changes: 2 additions & 4 deletions Jint/Runtime/StatementsCountOverflowException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;

namespace Jint.Runtime
namespace Jint.Runtime
{
public class StatementsCountOverflowException : Exception
public class StatementsCountOverflowException : JintException
{
public StatementsCountOverflowException() : base("The maximum number of statements executed have been reached.")
{
Expand Down
6 changes: 2 additions & 4 deletions Jint/Runtime/TypeErrorException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;

namespace Jint.Runtime
namespace Jint.Runtime
{
/// <summary>
/// Workaround for situation where engine is not easily accessible.
/// </summary>
internal sealed class TypeErrorException : Exception
internal sealed class TypeErrorException : JintException
{
public TypeErrorException(string message) : base(message)
{
Expand Down

0 comments on commit a8d19f3

Please sign in to comment.