Skip to content

ready() method rejects with string, instead of Error #654

Description

@spaiz

Hi there. I was totally surprised when my tests failed because the .ready() method threw a string, instead of an Error object. Was it done by purpose?

I'm talking about simple .ready() method usage (example from the documentation):

   try {
      await client.ready().catch((e) => { throw e; });
      // SDK is ready
    } catch(e) {
     console.log(typeof e);
    }

Result: string

I think we can agree it's a bad decision to throw anything except Error, but maybe there is a reason I don't understand.

Anyway, maybe it is worth updating documentation. Or, fix the bug and bump the minor version.

P.S.
Currently, the workaround is to wrap the string manually.

   try {
      await client.ready().catch((e) => { throw Error(e); });
      // SDK is ready
    } catch(e) {
     console.log(typeof e);
    }

Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions