Skip to content

how to handle error object #20

@arcollector

Description

@arcollector

If i understard correctly you can do something like this

try {
  someOtherJSFunctionThatThrows()
} catch {
| Not_found => ... // catch a ReScript exception
| Invalid_argument(_) => ... // catch a second ReScript exception
| Js.Exn.Error(obj) => ... // catch the JS exception
}

In my case I have something like this

Axios.get("some_url", ())
  ->Promise.then(response => {
    Promise.resolve(response.data)
  })
  ->Promise.catch(exn => {
    // exn is of type exn always, I need something like Js.Exn.t
    Promise.reject(exn)
  })

How to "cast" exn to Js.Exn.t ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions