Skip to content

Non-informative error message when API key is missing or incorrect #231

Description

@vitalir-xops

When the auth key is invalid the sdk throws a generic exception with non-informative error message which makes these kind of errors hard to catch.

Version: "shipengine": "^1.0.7",

Code example:

import { ShipEngine } from "shipengine";
const config = {
  apiKey: "TEST",
}

const addresses = [
  {
    name: "John Smith",
    companyName: "ShipStation",
    addressLine1: "3800 N Lamar Blvd",
    addressLine2: "#220",
    cityLocality: "Austin",
    stateProvince: "TX",
    postalCode: "78756",
    countryCode: "US",
    addressResidentialIndicator: "no",
  },
]
let shipengine = new ShipEngine(config);
const result = await shipengine.validateAddresses(addresses);

error message:

Error validating address:  response.map is not a function
Error validating address:  TypeError: response.map is not a function
    at Object.formatResponse (<path>/node_modules/shipengine/cjs/validate-addresses/format-response.js:5:21)
    at Object.validateAddresses (<path>/node_modules/shipengine/cjs/validate-addresses/index.js:19:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async validateAddresses (<path>/agent.js:20:20)
    ...

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