Laravel artisan exception details - laravel

When I run artisan command, I get no error details, no stack and line numbers.
is this normal?
How can I know where is the error coming from?
Thanks

You can run:
php artisan migrate --seed -vvv
to get more details.
You can also verify error log for details (by default storage/logs/laravel.log).

I would suggest
composer dump-autoload
Also delete files in bootstrap/cache directory.
If this does not help, may be search for AssignmentStatus in your project to get more details.

It's been catched by laravel.
You can dump the detail in the "handle" function in this file
/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php
public function handle($input, $output = null)
{
try {
$this->bootstrap();
return $this->getArtisan()->run($input, $output);
} catch (Exception $e) {
var_dump($e);die;
$this->reportException($e);
$this->renderException($output, $e);
return 1;
} catch (Throwable $e) {
$e = new FatalThrowableError($e);
$this->reportException($e);
$this->renderException($output, $e);
return 1;
}
}

Related

Laravel: Could not insert data but don't catch any error

I try to run a cronjob to insert about 60000 rows into DB:
DB::beginTransaction();
try {
DB::table('pharmacies')->delete();
foreach(array_chunk($data, 50) as $piece) {
Pharmacy::insert($piece);
}
DB::commit();
\Log::debug("Save successfully");
} catch(\Exception $e) {
DB::rollback();
\Log::debug($e->getMessage());
}
}
The cronjob is working normally. I test for a few first times, it saves successfully. But then, It suddenly can't save and from this time the data can't save without any error.
I don't know why the data can't save but it doesn't catch exceptions to log the error message?
Any idea or suggestion for this case. Please help me. Thank you so much!
What is your CORN-JOB configuration? check /var/log/syslog for logs

Batch update not working in pgsql database laravel

I want to update data by batch that always goes to catch. I am using pgsql database.
I followed this tutorial
https://github.com/mavinoo/laravelBatch
$tbc = $this->gradeService->updateGrade($request);
try{
if(count($tbc) > 0)
\Batch::update('grades',$tbc,'id');
}catch(\Exception $e){
return "OOps, an error occured";
}
return back()->with('status', 'Saved');
This part of code always execute catch. How can i solve this problem?

Laravel package whoops exception

In my Laravel package I have this code:
try {
$var_msg = "Exception example";
throw new InvalidNameException($var_msg);
}
catch (InvalidNameException $e) {
abort(403, $e->getMessage());
//report($e);Exception Log
}
The error is displayed as html error page. But, I'd like to report the error as an whoops error.
Take this code as reference.
$whoops = new \Whoops\Run();
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
// Set Whoops as the default error and exception handler used by PHP:
$whoops->register();
throw new \RuntimeException("Oopsie!");

Unable to catch error in laravel using try catch

I wrote a code to try and catch error.
I want that if the error occurs then laravel continues to the next one and i write the error in the error file as shown here.
Laravel's black page of error pops up which shows "ErrorException (E_WARNING) followed by the whole error on the left page and the programme is abruptly stopped.
Is there a way to skip the error notification which brings my whole code to a stop.
My attempt at coding to catch the error is here:
try {
$jsondata_car = (file_get_contents($urltofind_car));
} catch (Exception $e) {
$errorfile = fopen("errors", 'a');
fwrite($errorfile, $e - > getmessage().
"\n");
$failed_car = 9999999;
report($e);
return false;
}
Am I missing out something?
The error I get is here
file_get_contents(): failed to open stream:
HTTP request failed! HTTP/1.1 400 Bad Request
The error is shown on the line
$jsondata_car = (file_get_contents($urltofind_car));
The solution is here
Exception is used which should have contained a namespace.
The problem is that this does not throw up an error even though I had not written
Use Exception;
at the beginning.
As suggested by #simon R I made the rectification and it worked.
It is most likely still throwing the error because you haven't imported the Exception class
Ensure you either add
Use Exception;
to your class.
Alternative update your code to namespace it;
try {
$jsondata_car = (file_get_contents($urltofind_car));
} catch (\Exception $e) {
$errorfile = fopen("errors", 'a');
fwrite($errorfile, $e - > getmessage().
"\n");
$failed_car = 9999999;
report($e);
return false;
}

Unable to catch adLDAP Exception on Laravel 5.1?

When I get an exception while running the below code, it does not return the exception message but loads Laravel’s error handling page. I’m trying to return the exception error message.
try {
$adldap = new adLDAP(Config::get('app.ldap'));
}
catch (adLDAPException $e) {
return $e;
}
I just encountered this issue and discovered that AdLDAP 5.0.0 onwards requires you to use 'adLDAP\Exceptions\adLDAPException'.
Rob Ganly

Resources