Skip to content
Closed
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
4 changes: 4 additions & 0 deletions src/fable-library-ts/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class Exception {
constructor(msg?: string) {
this.message = msg ?? "";
}

toString() {
return this.message;
}
}

export function isException(x: any) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Js/Main/TypeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,15 @@ let tests =
| ex -> (false, "unknown", 0.)
|> equal (true, "Code: 5", 5.5)

testCase "Exception ToString contains the message" <| fun () -> // See #4197
let msg =
try
failwith "test message"
""
with ex -> ex.ToString()
// .NET returns "System.Exception: test message", Fable returns just the message
msg.Contains("test message") |> equal true

testCase "reraise works" <| fun () ->
try
try
Expand Down
Loading