Fix error handling in BulkAssetsController

Updated error handling to ensure all exceptions are properly stored in the errors array and removed unused custom_field_problem variable. Also, uncommented location assignment code in UpdateAssetAction for clearer logic.
This commit is contained in:
spencerrlongg 2024-11-19 17:56:56 -06:00
parent 3cf583ab03
commit 0353c7a03b
2 changed files with 6 additions and 6 deletions

View file

@ -193,7 +193,7 @@ class UpdateAssetAction
if ($asset->save()) { if ($asset->save()) {
// check out stuff // check out stuff
//$location = Location::find($asset->location_id); $location = Location::find($asset->location_id);
if (!is_null($assigned_user) && ($target = User::find($assigned_user))) { if (!is_null($assigned_user) && ($target = User::find($assigned_user))) {
$location = $target->location_id; $location = $target->location_id;
} elseif (!is_null($assigned_asset) && ($target = Asset::find($assigned_asset))) { } elseif (!is_null($assigned_asset) && ($target = Asset::find($assigned_asset))) {

View file

@ -244,9 +244,9 @@ class BulkAssetsController extends Controller
// catch exceptions // catch exceptions
} catch (ValidationException $e) { } catch (ValidationException $e) {
$errors[$key] = $e->getMessage(); $errors[$key] = $e->getMessage();
} catch (CustomFieldPermissionException $e) { } catch (CustomFieldPermissionException $e) {
$custom_field_problem = true; $errors[$key] = $e->getMessage();
//$custom_field_problem = true;
} catch (\Exception $e) { } catch (\Exception $e) {
report($e); report($e);
$errors[$key] = trans('general.something_went_wrong'); $errors[$key] = trans('general.something_went_wrong');
@ -255,9 +255,9 @@ class BulkAssetsController extends Controller
if (!empty($errors)) { if (!empty($errors)) {
return redirect($bulk_back_url)->with('bulk_asset_errors', $errors); return redirect($bulk_back_url)->with('bulk_asset_errors', $errors);
} }
if ($custom_field_problem) { //if ($custom_field_problem) {
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.encrypted_warning')); // return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.encrypted_warning'));
} //}
return redirect($bulk_back_url)->with('success', trans('bulk.update.success')); return redirect($bulk_back_url)->with('success', trans('bulk.update.success'));
} }