-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error catching and Typescript: Object is of type 'unknown' #320
Comments
Hello @soullivaneuh, Thanks for the feedback and sharing all these details about your issue. The team is looking into it |
Hey @soullivaneuh, I am going to add an ApiError type that should help.
Also, you can define your custom error handler when instantiating the API:
|
Fix in release 1.30.1 |
Currently have import {
ApiError
} from 'mangopay2-nodejs-sdk'; How am I supposed to use it? |
import * as Mangopay from 'mangopay2-nodejs-sdk';
let error : Mangopay.models.ApiError |
Since I upgraded my project to Typescript 4.4+, any catch error is considered as
unknown
and its type has to be verified.This article well explain the situation: https://bobbyhadz.com/blog/typescript-object-is-of-type-unknown
I have the case with this library. Considering the following code sample:
Gives me the following Typescript error:
This should be something solvable by using
instanceof
with the right error instance type. For example with a Joi validation error catch:However, I did not find any typing representing the MangoPay error containing the
Type
property on this library.Did I miss something or is it something that need to be updated on that project? 🤔
The text was updated successfully, but these errors were encountered: