Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

balena-errors

balena-io-modules54.9kApache-2.04.9.0TypeScript support: included

Collection of Balena JavaScript errors

balena, resin, errors

readme

balena-errors

Balena error collection

npm version dependencies Build Status Build status ![Gitter](https://badges.gitter.im/Join Chat.svg) Sauce Test Status

Role

The intention of this module is to provide a collection of Error instances to be used by the Balena SDK.

THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.

Unless you know what you're doing, use the Balena SDK instead.

Deprecation - note to developers / contributors

While this module has not been formally deprecated, we now believe that it is not good practice to add error classes to a separate module like balena-errors. Instead, error classes should be added to the same module that throws the errors. The reason is that downstream applications (like the balena CLI) may end up with multiple versions of balena-errors in the node_modules folder, in order to satisfy dependencies' own dependencies (e.g. a dependency module requires balena-errors v4, and another dependency module requires balena-errors v3). When this happens, testing error instances with instanceof fails: For example, an error class like BalenaExpiredToken loaded from balena-errors v4 would be considered incompatible (not the same class) as BalenaExpiredToken loaded from balena-errors v3. And this leads to bugs...

Installation

Install balena-errors by running:

$ npm install --save balena-errors

Documentation

errors~BalenaTooManyRequests

Kind: inner class of errors
Summary: Balena too many requests
Access: public

new BalenaTooManyRequests(nextValidRequestDate)

Returns: Error - error instance

Param Type Description
nextValidRequestDate String next valid request string date

Example

throw new errors.BalenaTooManyRequests()

errors~BalenaInvalidLoginCredentials

Kind: inner class of errors
Summary: Balena invalid login credentials
Access: public

errors~BalenaInvalidDeviceType

Kind: inner class of errors
Summary: Balena invalid device type
Access: public

new BalenaInvalidDeviceType(type)

Returns: Error - error instance

Param Type Description
type String device type

Example

throw new errors.BalenaInvalidDeviceType('raspberry-pi')

errors~BalenaDiscontinuedDeviceType

Kind: inner class of errors
Summary: Balena discontinued device type
Access: public

new BalenaDiscontinuedDeviceType(type)

The device type that you specified is invalid because it is discontinued, and this operation is no longer supported.

Returns: Error - error instance

Param Type Description
type String device type

Example

throw new errors.BalenaDiscontinuedDeviceType('edge')

errors~BalenaMalformedToken

Kind: inner class of errors
Summary: Balena malformed token
Access: public

new BalenaMalformedToken(token)

Returns: Error - error instance

Param Type Description
token String token

Example

throw new errors.BalenaMalformedToken('1234')

errors~BalenaSettingsPermissionError

Kind: inner class of errors
Summary: Balena settings permission error
Access: public

new BalenaSettingsPermissionError(error)

Returns: Error - error instance

Param Type Description
error Error usually an EACCESS error

Example

throw new errors.BalenaSettingsPermissionError()

errors~BalenaSupervisorLockedError

Kind: inner class of errors
Summary: The device supervisor is locked
Access: public

new BalenaSupervisorLockedError(token)

Returns: Error - error instance

Param Type Description
token String token

Example

throw new errors.BalenaSupervisorLockedError()

errors~BalenaExpiredToken

Kind: inner class of errors
Summary: Balena expired token
Access: public

new BalenaExpiredToken(token)

Returns: Error - error instance

Param Type Description
token String token

Example

throw new errors.BalenaExpiredToken('1234')

errors~BalenaApplicationNotFound

Kind: inner class of errors
Summary: Balena application not found
Access: public

new BalenaApplicationNotFound(application)

Returns: Error - error instance

Param Type Description
application String | Number application name or id

Example

throw new errors.BalenaApplicationNotFound('MyApp')

errors~BalenaReleaseNotFound

Kind: inner class of errors
Summary: Balena release not found
Access: public

new BalenaReleaseNotFound(release)

Returns: Error - error instance

Param Type Description
release String | Number release commit or id

Example

throw new errors.BalenaReleaseNotFound(123)

errors~BalenaOrganizationMembershipRoleNotFound

Kind: inner class of errors
Summary: Balena organization membership role not found
Access: public

new BalenaOrganizationMembershipRoleNotFound(organizationMembershipRole)

Returns: Error - error instance

Param Type Description
organizationMembershipRole String | Number organization membership role name or id

Example

throw new errors.BalenaOrganizationMembershipRoleNotFound(123)

errors~BalenaApplicationMembershipRoleNotFound

Kind: inner class of errors
Summary: Balena application membership role not found
Access: public

new BalenaApplicationMembershipRoleNotFound(applicationMembershipRole)

Returns: Error - error instance

Param Type Description
applicationMembershipRole String | Number application membership role name or id

Example

throw new errors.BalenaApplicationMembershipRoleNotFound(123)

errors~BalenaImageNotFound

Kind: inner class of errors
Summary: Balena image not found
Access: public

new BalenaImageNotFound(image)

Returns: Error - error instance

Param Type Description
image Number image id

Example

throw new errors.BalenaImageNotFound(123)

errors~BalenaServiceNotFound

Kind: inner class of errors
Summary: Balena service not found
Access: public

new BalenaServiceNotFound(service)

Returns: Error - error instance

Param Type Description
service String | Number service name or id

Example

throw new errors.BalenaServiceNotFound(123)

errors~BalenaDeviceNotFound

Kind: inner class of errors
Summary: Balena device not found
Access: public

new BalenaDeviceNotFound(device)

Returns: Error - error instance

Param Type Description
device String | Number device name or id

Example

throw new errors.BalenaDeviceNotFound('MyDevice')

errors~BalenaOrganizationNotFound

Kind: inner class of errors
Summary: Balena organization not found
Access: public

new BalenaOrganizationNotFound(organization)

Returns: Error - error instance

Param Type Description
organization String | Number organization name or id

Example

throw new errors.BalenaOrganizationNotFound('MyOrg')

errors~BalenaAmbiguousDevice

Kind: inner class of errors
Summary: Balena ambiguous device
Access: public

new BalenaAmbiguousDevice(device)

Returns: Error - error instance

Param Type Description
device String | Number device name or id

Example

throw new errors.BalenaAmbiguousDevice('MyDevice')

errors~BalenaAmbiguousApplication

Kind: inner class of errors
Summary: Balena ambiguous application
Access: public

new BalenaAmbiguousApplication(application)

Returns: Error - error instance

Param Type Description
application String | Number application name or id

Example

throw new errors.BalenaAmbiguousApplication('MyApp')

errors~BalenaAmbiguousRelease

Kind: inner class of errors
Summary: Balena ambiguous release
Access: public

new BalenaAmbiguousRelease(release)

Returns: Error - error instance

Param Type Description
release String release hash

Example

throw new errors.BalenaAmbiguousRelease('7cf02a6')

errors~BalenaKeyNotFound

Kind: inner class of errors
Summary: Balena key not found
Access: public

new BalenaKeyNotFound(key)

Returns: Error - error instance

Param Type Description
key String | Number key name, id or value

Example

throw new errors.BalenaKeyNotFound('MyKey')

errors~BalenaRequestError

Kind: inner class of errors
Summary: Balena request error
Access: public

new BalenaRequestError(body, statusCode, [requestOptions], [responseHeaders])

Returns: Error - error instance

Param Type Description
body String response body
statusCode Number http status code
[requestOptions] Object options used to make the request
[responseHeaders] Object the Headers that were included in the response

Example

throw new errors.BalenaRequestError('Unauthorized')

errors~BalenaNotLoggedIn

Kind: inner class of errors
Summary: Balena not logged in
Access: public

errors~BalenaInvalidParameterError

Kind: inner class of errors
Summary: Balena invalid parameter
Access: public

Support

If you're having any problem, please raise an issue on GitHub and the Balena team will be happy to help.

Tests

Run the test suite by doing:

$ gulp test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ gulp lint

License

The project is licensed under the Apache 2.0 license.

changelog

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

2.13.0 - 2018-05-24

v5.0.0

(2023-11-07)

  • Move the sources from lib to src [Thodoris Greasidis]
  • Update dependencies [Thodoris Greasidis]
  • Update TypeScript to 5.2.2 [Thodoris Greasidis]
  • Target es2019 runtimes [Thodoris Greasidis]
  • Drop support for node < 18 [Thodoris Greasidis]

v4.9.0

(2023-11-01)

  • Add an optional responseHeaders property to BalenaRequestError [Thodoris Greasidis]

v4.8.1

(2023-11-01)

  • Drop mochainon [Thodoris Greasidis]
  • tsconfig: Enable skipLibCheck to avoid @types/glib issue [Thodoris Greasidis]

v4.8.0

(2023-07-10)

  • Overload BalenaServiceNotFound error to also accept a service name [Thodoris Greasidis]

v4.7.3

(2022-11-01)

  • Disable source maps since they do not work [JSReds]

v4.7.2

(2022-11-01)

  • Replace balenaCI with flowzone [Thodoris Greasidis]

v4.7.1

(2020-10-22)

  • Add deprecation note to Readme [Paulo Castro]

v4.7.0

(2020-09-29)

  • Add BalenaSettingsPermissionError [josecoelho]

v4.6.0

(2020-09-24)

  • Add Organization membership role not found error [Amit Solanki]

v4.5.1

(2020-09-10)

  • karmaConfig: fix tests against node 10 [JSReds]
  • Fix catch-uncommited check on newer balenaCI [Thodoris Greasidis]
  • Test on travis against more modern node versions [Thodoris Greasidis]
  • balena-config-karma: update to v3.0.0 [JSReds]

v4.5.0

(2020-09-08)

  • Errors: add authentication errors [JSReds]

v4.4.1

(2020-07-03)

  • Update dependencies [Pagan Gazzard]

v4.4.0

(2020-05-01)

  • Add Application membership role not found error [Amit Solanki]

v4.3.2

(2020-04-03)

  • Mark BalenaSupervisorLockedError token parameter as optional [Pagan Gazzard]

v4.3.1

(2020-04-03)

  • Use balena-lint for linting [Pagan Gazzard]

v4.3.0

(2020-03-25)

  • Allow string argument in the BalenaReleaseNotFound constructor [Thodoris Greasidis]

4.2.1 - 2020-01-20

  • Remove the token from the error message to avoid leaking [Pagan Gazzard]

4.2.0 - 2019-09-12

  • Add BalenaOrganizationNotFound [Thodoris Greasidis]

4.1.2 - 2019-09-12

  • Explicitly include build output in packaged releases [Thodoris Greasidis]
  • Test that the non-ignored emitted output is committed [Thodoris Greasidis]
  • Use a prepare step that doesn't run tests, to be balenaCI compliant [Thodoris Greasidis]
  • Exclude the build output from the repo [Thodoris Greasidis]
  • Add missing build & README output [Thodoris Greasidis]

4.1.1 - 2019-09-11

  • Bump TS version for tests & test typings against the previous version [Thodoris Greasidis]

4.1.0 - 2019-05-31

  • Add BalenaAmbiguousRelease error [Thodoris Greasidis]

v4.0.1 - 2018-10-23

  • Emit ES6 TS output [Tim Perry]

v4.0.0 - 2018-10-22

  • Require Node 6+ [Tim Perry]
  • Generate type definitions & update typed-error [Tim Perry]

v3.0.0 - 2018-10-16

  • Remove the deprecated BuildNotFound error [Tim Perry]
  • Rename everything 'resin' to 'balena' [Tim Perry]

  • Add ResinServiceNotFound

2.12.0 - 2017-11-14

  • Add ImageNotFound error, for multicontainer

2.11.0 - 2017-11-13

  • Add ReleaseNotFound error, and deprecate BuildNotFound, for multicontainer

2.10.0 - 2017-09-22

  • Add ResinDiscontinuedDeviceType error

2.9.0 - 2017-09-05

  • Add ResinSupervisorLockedError error
  • Use the resin.io shared typings packages

2.8.0 - 2017-08-02

  • Converted to TypeScript
  • Switched to testing in Chrome Headless, updated the list of browsers used for testing in Sauce Labs

2.7.0 - 2017-07-03

  • Add ResinInvalidParameterError error.

2.6.0 - 2017-03-09

  • Stop running tests for Node < 4
  • Add ResinBuildNotFound error.

2.5.0 - 2017-02-21

  • Include request options in ResinRequestError

2.4.0 - 2016-04-28

  • Add ResinAmbiguousApplication error.

2.3.0 - 2016-03-03

  • Add ResinExpiredToken error.

2.2.0 - 2016-01-24

  • Add statusCode property to ResinRequestError.

2.1.0 - 2016-01-12

Added

  • Add ResinAmbiguousDevice error.

2.0.1 - 2015-12-04

Changed

  • Omit tests from NPM package.