Skip to content

Commit dcd2144

Browse files
authored
Include messages in F# exceptions. (#492)
Modify the custom exception types to inherit from System.Exception so the message is reported in call stacks for unhandled exceptions.
1 parent 90c814f commit dcd2144

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

src/compiler/Restler.Compiler/CodeGenerator.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ let TAB = @" "
1313
let RETURN = @"\r\n"
1414
let SPACE = @" "
1515

16+
type UnsupportedType (msg:string) =
17+
inherit Exception(msg)
18+
1619
exception UnsupportedAccessPath
17-
exception UnsupportedType of string
1820

1921
module Types =
2022
type RequestPrimitiveTypeData =

src/compiler/Restler.Compiler/Compiler.fs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ open Restler.Utilities.Logging
2222
open Restler.Utilities.Operators
2323
open Restler.XMsPaths
2424

25-
exception UnsupportedParameterSerialization of string
25+
type UnsupportedParameterSerialization (msg:string) =
26+
inherit Exception(msg)
2627

2728
module Types =
2829
/// A configuration associated with a single Swagger document

src/compiler/Restler.Compiler/Dependencies.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ open Restler.ApiResourceTypes
1414
open Restler.DependencyAnalysisTypes
1515
open Restler.Annotations
1616

17-
exception UnsupportedType of string
17+
type UnsupportedType (msg:string) =
18+
inherit Exception(msg)
19+
1820
exception InvalidSwaggerEndpoint
1921

2022
/// Determines whether a producer is valid for a given consumer.

src/compiler/Restler.Compiler/Dictionary.fs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ open Restler.ApiResourceTypes
88
open Restler.Utilities.Operators
99
open Restler.AccessPaths
1010

11-
exception InvalidMutationsDictionaryFormat of string
11+
type InvalidMutationsDictionaryFormat (msg:string) =
12+
inherit System.Exception(msg)
1213

1314
type MutationsDictionary =
1415
{

src/compiler/Restler.Compiler/Swagger.fs

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ module Restler.Swagger
66
open Microsoft.FSharpLu.File
77
open NSwag
88

9-
exception UnexpectedSwaggerParameter of string
10-
exception UnsupportedParameterSchema of string
11-
exception ParameterTypeNotFound of string
9+
type UnexpectedSwaggerParameter (msg:string) =
10+
inherit System.Exception(msg)
11+
type UnsupportedParameterSchema (msg:string) =
12+
inherit System.Exception(msg)
13+
type ParameterTypeNotFound (msg:string) =
14+
inherit System.Exception(msg)
1215

1316
let at x = Async.AwaitTask(x)
1417

src/compiler/Restler.Compiler/SwaggerVisitors.fs

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ open Restler.Utilities.Operators
1010
open Newtonsoft.Json.Linq
1111
open NJsonSchema
1212

13-
exception UnsupportedType of string
14-
exception NullArraySchema of string
15-
exception UnsupportedArrayExample of string
16-
exception UnsupportedRecursiveExample of string
13+
type UnsupportedType (msg:string) =
14+
inherit Exception(msg)
1715

16+
type NullArraySchema (msg:string) =
17+
inherit Exception(msg)
18+
19+
type UnsupportedArrayExample (msg:string) =
20+
inherit Exception(msg)
21+
22+
type UnsupportedRecursiveExample (msg:string) =
23+
inherit Exception(msg)
1824

1925
module SchemaUtilities =
2026

0 commit comments

Comments
 (0)