Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-99762

Make tojson(Error(...)) return an Error(...) constructor

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2025-02-03
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The current result of tojson(new Error("disaster")) is Error : disaster. This is not a valid JSON, because it misses the quotes: "Error : disaster". This is also not a valid JSON.stringify(Error("disaster")) result, because it returns an empty object {} since Error properties are not enumerable.

      Probably the best way to fix this is to return Error("disaster") string. This is also not a valid JSON, but it is evaluable similar to other evaluable tojson() results like Timestamp(1242436, 0) or NumberDecimal(13,44).

            Assignee:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Reporter:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: