oliyh / martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more
MIT License
525 stars 42 forks source link

Improve error handling #201

Open velios opened 2 months ago

velios commented 2 months ago

Hello. First of all, thx for exellent lib.

I happened to be parsing someone else's API and came across this probably incorrect entry. This example with error, i know that. The problem is not that it is incorrect, but that an uninformative error was received.

Problem json part

"responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "profiles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": "string",  // problem here when (keys schema) call on "string" value as schema arg
                          "depth": "number",
                          "site-id": "string"
                        },
                        "required": [
                          "id",
                          "depth"
                        ],
                        "example": "some example"
                      }
                    }
                  },
                 ...

Current exception is

#error {
 :cause nil
 :via
 [{:type java.lang.ClassCastException
   :message nil}]
 :trace
 []}

I would like to somehow improve the output for such cases, since I came across it. The wording does not stand up to criticism, I understand, so I hope that you will find the time to correct it for an understandable error.

oliyh commented 2 months ago

Hello!

Thank you for your contribution. I agree the existing message is not very helpful. I will hopefully find time to look at this more closely soon.

Cheers

velios commented 2 months ago

What’s worse is that with some errors I can get an instance with partially loaded apis. Since in this case I will not receive the correct notification of problems, I will assume that my entire API has loaded.