src/cmd/device-util.js
function getDevice({ id, api, auth, displayName = null, dontThrow = false }) {
	const p = when.resolve().then(() => api.getDevice({ deviceId: id, auth }))
		.then(r => r.body)
		.catch(e => {
			if (e.statusCode === 403 || e.statusCode === 404) {
				if (dontThrow) {
					return null;
				}
				throw new Error(`Device not found: ${displayName || id}`);
			}
			throw e;
		});
	return spin(p, 'Getting device information...');
}
function getDevice({ id, api, auth, displayName = null, dontThrow = false }) {
	const p = when.resolve().then(() => api.getDevice({ deviceId: id, auth }))
		.then(r => r.body)
		.catch(e => {
			if (e.statusCode === 403 || e.statusCode === 404) {
				if (dontThrow) {
					return null;
				}
				throw new Error(`Device not found: ${displayName || id}`);
			}
			throw e;
		});
	return spin(p, 'Getting device information...');
}
function getDevice ( { id , api , auth , displayName = null , dontThrow = false } ) { const p = when . resolve ( ) . then ( ( ) => api . getDevice ( { deviceId : id , auth } ) ) . then ( r => r . body ) . catch ( e => { if ( e . statusCode === 403 || e . statusCode === 404 ) { if ( dontThrow ) { return null ; } throw new Error ( ` ${ displayName || id } ` ) ; } throw e ; } ) ; return spin ( p , 'Getting device information...' ) ; }
Get device attributes.

@param {Object} options Options.
@param {String} options.id Device ID or name.
@param {Object} options.api API client.
@param {String} options.auth Access token.
@param {String} [options.displayName] Device name as shown to the user.
@param {Boolean} [options.dontThrow] Return 'null' instead of throwing an error if the device cannot be found.
@param {Promise<Object>}
Get device attributes .