Skip to content

Using instanceof to detect a pageError #58

@haveaguess

Description

@haveaguess

I want to detect when a page doesnt exist so Im catching exceptions, and trying to work out if the exception is a pageError.

So Im trying to use :

      if (wikiError instanceof pageError) {

It works if I import the class using :

import { pageError } from "wikipedia/dist/errors";

..but if I use the barrelled main export types from the d.ts like so

import { pageError } from "wikipedia";

It fails with

Right-hand side of 'instanceof' is not an object

Obviously I don't want to rely on digging into the dist folder, any ideas?

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