public function handleError($errorCode, $message, $content, $url)
    {
        if (! is_string($message)) {
            $message = $message->getReasonPhrase();
        }

        $message .= " - {$content} - {$url}";

        switch ($errorCode) {
            case 400:
                return new DiscordRequestFailedException("Error code 400: We sent a bad request. {$message}");
                break;
            case 403:
                return new NoPermissionsException("Error code 403: You do not have permission to do this. {$message}");
                break;
            case 404:
                return new NotFoundException("Error code 404: This resource does not exist. {$message}");
                break;
            case 500:
                if (Str::contains(strtolower($content), ['longer than 2000 characters', 'string value is too long'])) {
                    // Discord has set a restriction with content sent over REST,
                    // if it is more than 2000 characters long it will not be
                    // sent and will return a 500 error.
                    //
                    // There is no way around this, you must use WebSockets.
                    return new ContentTooLongException(
                        'The expected content was more than 2000 characters. Use websockets if you need this content.'
                    );
                }

                return new DiscordRequestFailedException(
                    "Error code 500: This usually means something went wrong with Discord. {$message}"
                );
                break;
            default:
                return new DiscordRequestFailedException(
                    "Error code {$errorCode}: There was an error processing the request. {$message}"
                );
                break;
        }
    }
public function handleError($errorCode, $message, $content, $url)
    {
        if (! is_string($message)) {
            $message = $message->getReasonPhrase();
        }

        $message .= " - {$content} - {$url}";

        switch ($errorCode) {
            case 400:
                return new DiscordRequestFailedException("Error code 400: We sent a bad request. {$message}");
                break;
            case 403:
                return new NoPermissionsException("Error code 403: You do not have permission to do this. {$message}");
                break;
            case 404:
                return new NotFoundException("Error code 404: This resource does not exist. {$message}");
                break;
            case 500:
                if (Str::contains(strtolower($content), ['longer than 2000 characters', 'string value is too long'])) {
                    // Discord has set a restriction with content sent over REST,
                    // if it is more than 2000 characters long it will not be
                    // sent and will return a 500 error.
                    //
                    // There is no way around this, you must use WebSockets.
                    return new ContentTooLongException(
                        'The expected content was more than 2000 characters. Use websockets if you need this content.'
                    );
                }

                return new DiscordRequestFailedException(
                    "Error code 500: This usually means something went wrong with Discord. {$message}"
                );
                break;
            default:
                return new DiscordRequestFailedException(
                    "Error code {$errorCode}: There was an error processing the request. {$message}"
                );
                break;
        }
    }
public function handleError ( $ errorCode , $ message , $ content , $ url ) { if ( ! is_string ( $ message ) ) { $ message = $ message -> getReasonPhrase ( ) ; } $ message .= " - {$content} - {$url}" ; switch ( $ errorCode ) { case 400 : return new DiscordRequestFailedException ( "Error code 400: We sent a bad request. {$message}" ) ; break ; case 403 : return new NoPermissionsException ( "Error code 403: You do not have permission to do this. {$message}" ) ; break ; case 404 : return new NotFoundException ( "Error code 404: This resource does not exist. {$message}" ) ; break ; case 500 : if ( Str :: contains ( strtolower ( $ content ) , [ 'longer than 2000 characters' , 'string value is too long' ] ) ) { // Discord has set a restriction with content sent over REST, // if it is more than 2000 characters long it will not be // sent and will return a 500 error. // // There is no way around this, you must use WebSockets. return new ContentTooLongException ( 'The expected content was more than 2000 characters. Use websockets if you need this content.' ) ; } return new DiscordRequestFailedException ( "Error code 500: This usually means something went wrong with Discord. {$message}" ) ; break ; default : return new DiscordRequestFailedException ( "Error code {$errorCode}: There was an error processing the request. {$message}" ) ; break ; } }
Handles an error code.

@param int             $errorCode The HTTP status code.
@param string|Response $message   The HTTP reason phrase.
@param string          $content   The HTTP response content.
@param string          $url       The HTTP url.

@return \Discord\Exceptions\DiscordRequestFailedException Returned when the request fails.
@return \Discord\Exceptions\Rest\ContentTooLongException  Returned when the content is longer than 2000
characters.
@return \Discord\Exceptions\Rest\NotFoundException        Returned when the server returns 404 Not Found.
@return \Discord\Exceptions\Rest\NoPermissionsException   Returned when you do not have permissions to do
something.
Handles an error code .