islamic-network / alquran.cloud

Web App that powers https://alquran.cloud
GNU General Public License v3.0
317 stars 44 forks source link

Error when input wrong ayah #3

Closed hahn closed 6 years ago

hahn commented 7 years ago

error slim show up when input wrong ayah (or non-numeric ayah). example: https://alquran.cloud/ayah?reference=113%3A-2

get error like this:

The application could not run because of the following error:

Details

Type: GuzzleHttp\Exception\ClientException
Code: 400
Message: Client error: `GET http://api.alquran.cloud/ayah/113:eee/quran-uthmani` resulted in a `400 Bad Request` response: {"code":400,"status":"Bad Request","data":"Please specify a valid surah reference in the format Surah:Ayat (2:255)."}
File: /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
Line: 113
Trace

#0 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/www/vhosts/alquran.cloud/www/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait()
#10 /var/www/vhosts/alquran.cloud/www/vendor/alquran/api-client/src/AlQuranCloud/ApiClient/Client.php(66): GuzzleHttp\Client->request('GET', 'http://api.alqu...', Array)
#11 /var/www/vhosts/alquran.cloud/www/vendor/alquran/api-client/src/AlQuranCloud/ApiClient/Client.php(180): AlQuranCloud\ApiClient\Client->connect('http://api.alqu...')
#12 /var/www/vhosts/alquran.cloud/www/routes/ayah.php(12): AlQuranCloud\ApiClient\Client->ayah('113:eee', 'quran-uthmani')
#13 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#14 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#15 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/Route.php(344): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#16 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#17 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#18 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/App.php(476): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#19 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#20 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/App.php(370): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#21 /var/www/vhosts/alquran.cloud/www/vendor/slim/slim/Slim/App.php(295): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#22 /var/www/vhosts/alquran.cloud/www/www/index.php(15): Slim\App->run()
#23 {main}

Btw, thanks for the API. it's cool. keep good work :)

*ps: sorry for my bad english :D

meezaan commented 7 years ago

Al Salaamu Alaykum,

This is expected behaviour (because the promise to receive a response from the API was not fulfilled), except the error reporting probably needs to be turned off and maybe we add a page within the application design template to display the error instead of the default Slim page.

Thanks for raising the issue and you're welcome.

PS - if you'd like to do this before I get to it, please feel free to and raise a Pull Request.