Skip to content
Browse files

Fix custom ending bug affecting non-truthy endings, update documentat…

…ion for API error updates
  • Loading branch information...
cydrobolt committed Mar 20, 2017
1 parent 861665f commit b643906752040b337eff1a91cf0fb7d4ba049e4a
@@ -55,14 +55,14 @@ public static function createLink($long_url, $is_secret=false, $custom_ending=nu
looks like a shortened URL.');
if (!$is_secret && !$custom_ending && (LinkHelper::longLinkExists($long_url) !== false)) {
if (!$is_secret && (!isset($custom_ending)) && (LinkHelper::longLinkExists($long_url) !== false)) {
// if link is not specified as secret, is non-custom, and
// already exists in Polr, lookup the value and return
$existing_link = LinkHelper::longLinkExists($long_url);
return self::formatLink($existing_link);
if ($custom_ending) {
if (isset($custom_ending)) {
// has custom ending
$ending_conforms = LinkHelper::validateEnding($custom_ending);
if (!$ending_conforms) {
@@ -33,7 +33,7 @@ public function shortenLink(Request $request) {
$formatted_link = LinkFactory::createLink($long_url, $is_secret, $custom_ending, $link_ip, $user->username, false, true);
catch (\Exception $e) {
throw new ApiException('CREATE_ERROR', $e->getMessage(), 400, $response_type);
throw new ApiException('CREATION_ERROR', $e->getMessage(), 400, $response_type);
return self::encodeResponse($formatted_link, 'shorten', $response_type);
@@ -218,13 +218,15 @@ This status code is returned in the following circumstances:
Example `json` error response:
"error": "custom ending already in use"
"error":"Quota exceeded."
Example `plain_text` error response:
`custom ending already in use`
`429 Quota exceeded.`
## Testing the API
@@ -0,0 +1,19 @@
## API Error Text Codes

`SERVER_ERROR`: A generic, unhandled error has occured.

`JSON_ONLY`: Only JSON-encoded data is available for this endpoint.

`MISSING_PARAMETERS`: Invalid or missing parameters.

`NOT_FOUND`: Object not found.

`ACCESS_DENIED`: User is not authorized to access the object.

`INVALID_ANALYTICS_TYPE`: Invalid analytics type requested.

`CREATION_ERROR`: An error occurred while creating the object.

`AUTH_ERROR`: An error occured while attempting to authenticate the user to the API.

`QUOTA_EXCEEDED`: User's API usage has exceeded alloted quota.
@@ -8,6 +8,7 @@ pages:
- Developer Guide:
- 'Libraries': 'developer-guide/'
- 'API Documentation': 'developer-guide/'
- 'API Errors': 'developer-guide/'
- About:
- 'License': 'about/'
- 'Contributors': 'about/'

0 comments on commit b643906

Please sign in to comment.
You can’t perform that action at this time.