61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System;
|
|
using System.Runtime.Remoting;
|
|
using System.Security.Permissions;
|
|
using AspClassic.Scripting.Runtime;
|
|
using AspClassic.Scripting.Utils;
|
|
|
|
namespace AspClassic.Scripting.Hosting;
|
|
|
|
public sealed class ExceptionOperations : MarshalByRefObject
|
|
{
|
|
private readonly LanguageContext _context;
|
|
|
|
internal ExceptionOperations(LanguageContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public string FormatException(Exception exception)
|
|
{
|
|
return _context.FormatException(exception);
|
|
}
|
|
|
|
public void GetExceptionMessage(Exception exception, out string message, out string errorTypeName)
|
|
{
|
|
_context.GetExceptionMessage(exception, out message, out errorTypeName);
|
|
}
|
|
|
|
public bool HandleException(Exception exception)
|
|
{
|
|
ContractUtils.RequiresNotNull(exception, "exception");
|
|
return false;
|
|
}
|
|
|
|
public string FormatException(ObjectHandle exception)
|
|
{
|
|
Exception ex = exception.Unwrap() as Exception;
|
|
ContractUtils.Requires(ex != null, "exception", "ObjectHandle must be to Exception object");
|
|
return _context.FormatException(ex);
|
|
}
|
|
|
|
public void GetExceptionMessage(ObjectHandle exception, out string message, out string errorTypeName)
|
|
{
|
|
Exception ex = exception.Unwrap() as Exception;
|
|
ContractUtils.Requires(ex != null, "exception", "ObjectHandle must be to Exception object");
|
|
_context.GetExceptionMessage(ex, out message, out errorTypeName);
|
|
}
|
|
|
|
public bool HandleException(ObjectHandle exception)
|
|
{
|
|
Exception ex = exception.Unwrap() as Exception;
|
|
ContractUtils.Requires(ex != null, "exception", "ObjectHandle must be to Exception object");
|
|
ContractUtils.RequiresNotNull(ex, "exception");
|
|
return false;
|
|
}
|
|
|
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
|
|
public override object InitializeLifetimeService()
|
|
{
|
|
return null;
|
|
}
|
|
}
|