Skip to content

Commit

Permalink
Better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gnikyt committed May 23, 2018
1 parent a34da8b commit 6808a84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/OhMyBrew/BasicShopifyAPI.php
Expand Up @@ -411,12 +411,12 @@ public function graph(string $query)
throw new Exception('Shopify domain missing for API calls');
}

if ($this->private && $this->apiPassword === null) {
if ($this->private && ($this->apiPassword === null && $this->accessToken === null)) {
// Private apps need password for use as access token
throw new Exception('API password required for Shopify GraphQL calls');
throw new Exception('API password/access token required for private Shopify GraphQL calls');
} elseif (!$this->private && $this->accessToken === null) {
// Need access token for public calls
throw new Exception('Access token required for Shopify GraphQL calls');
throw new Exception('Access token required for public Shopify GraphQL calls');
}

// Create the request, pass the access token and optional parameters
Expand Down
4 changes: 2 additions & 2 deletions test/GraphApiTest.php
Expand Up @@ -75,7 +75,7 @@ public function itShouldThrowExceptionForMissingDomainOnQuery()
/**
* @test
* @expectedException Exception
* @expectedExceptionMessage API password required for Shopify GraphQL calls
* @expectedExceptionMessage API password/access token required for private Shopify GraphQL calls
*
* Ensure API password is there for private queries
*/
Expand All @@ -89,7 +89,7 @@ public function itShouldThrowExceptionForMissingApiPasswordOnPrivateQuery()
/**
* @test
* @expectedException Exception
* @expectedExceptionMessage Access token required for Shopify GraphQL calls
* @expectedExceptionMessage Access token required for public Shopify GraphQL calls
*
* Ensure access token is there for public queries
*/
Expand Down

0 comments on commit 6808a84

Please sign in to comment.