Как бросать значимые исключения в F # и ловить их в C #?
Со следующим кодом:
F # Библиотека:
module Test
exception TestExc of string
let throwit message : unit=
raise (TestExc("custom exception with message: " + message))
C # Клиент:
namespace TestExc
{
class Program
{
static void Main(string[] args)
{
try
{
Test.throwit("Hi there");
}
catch (Test.TestExc te)
{
Console.WriteLine("Caught exception with message: " + te.Message);
}
}
}
}
Я получаю следующее сообщение:
Caught exception with message: Exception of type 'Test+TestExc' was thrown.
Но я хочу видеть Hi there
в качестве перехваченного сообщения об исключении.
Что такое F # эквивалент следующего?
class CSTestExc:System.Exception
{
public CSTestExc(String message) : base(message) { }
}