Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3037

Correct types in ArgumentException message

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.11.0
    • Affects Version/s: None
    • Component/s: Builders
    • None
    • Minor Change

      Contributor description:

      Fixing expectation message whereby the wrong type is contained within the exception making it confusing to the end-user.

      Take for example the following test:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      [Fact]
      public void Test1()
      {
          PipelineDefinition<BsonDocument, MyType>.Create(new IPipelineStageDefinition[]
          {
              new JsonPipelineStageDefinition<BsonDocument, BsonDocument>(
                  @"{ project: { } } "),
          });
      }
      
      public class MyType { }
      

      This throws the following exception

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      
      System.ArgumentException : The output type to the last stage was expected to be MongoDB.Bson.BsonDocument, but was MongoDB.Bson.BsonDocument. (Parameter 'stages')
      

      instead of

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      
      System.ArgumentException : The output type to the last stage was expected to be SomeExample.MyType, but was MongoDB.Bson.BsonDocument. (Parameter 'stages')
      

      Contributor PR:
      https://github.com/mongodb/mongo-csharp-driver/pull/392

            Assignee:
            vincent.kam@mongodb.com Vincent Kam (Inactive)
            Reporter:
            vincent.kam@mongodb.com Vincent Kam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: