M
M
Maxim Spiridonov2015-05-09 07:28:03
Laravel
Maxim Spiridonov, 2015-05-09 07:28:03

How to catch error in laravel and handle it?

I connected a third-party script to laravel via macro. The script connects to a specific ip via fsockopen and then I perform some actions. The fact is that if the ip is not available, I will get an error:

ErrorException in Websend.php line 35:
fsockopen():

Therefore, I need to catch this error using laravel and warn the user that the ip is not available. What do i do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gregory, 2015-05-09
@difiso

From documentation.
fsockopen() returns a file pointer that can be passed to file functions (such as fgets(), fgetss(), fwrite(), fclose(), and feof()). If the call fails, the function will return FALSE.
You can also use the errno and errstr parameters.

T
Tesla, 2015-05-10
@Tesla

And what does Laravel tools have to do with it? Well, catch with PHPtry {...} catch (ErrorException $e) {...}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question