question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[4.1][Feature] Custom error message in case destroy() failed

See original GitHub issue

Right now there’s just one default message in case the destroy() method failed.

I’m using some nesting/relations and I want to prevent the user from deleting the resource in case it has some specific relations still defined.

From functional point of view, everything works ok. I’m overriding the destroy() method in the CrudController, doing the checks and failing the destroy if there’s a problem. But right now, there’s no way to tell the user about the specifics of the problem.

My approach would be to rewrite said part of list.blade.php slightly, to:

error: function(result) {
    // Show an alert with the result
    var notificationText = "{{ trans('backpack::crud.delete_confirmation_not_message') }}";

    // Is there anything custom we'd like to tell the user?
    if (result.responseJSON.text != undefined) {
        notificationText = result.responseJSON.text;
    }

    new PNotify({
      title: "{{ trans('backpack::crud.delete_confirmation_not_title') }}",
      text: notificationText,
      type: "warning"
    });
}

And with this, we are free to throw 409 (or some other 4**/5** code, if applicable) in the destroy() method with some text. (e.g. return response()->json(['text' => $error)], 409);)

It shouldn’t be a breaking change.

I don’t know if something like this isn’t a part of some other plans/PRs, so forgive me for not being informed, if that’s the case 😃

Is it worth a PR?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
tabacitucommented, Feb 11, 2020

Good news everyone! We’ll finally have this in 4.1 - if you’re interested please follow the PR here https://github.com/Laravel-Backpack/CRUD/pull/2393

2reactions
tabacitucommented, Aug 17, 2019

Oups - the issue was that we’d want to customize that error message. Reopening it and marking as to-do for 4.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix list for IBM WebSphere Application Server Liberty
Fixes for WebSphere Application Server Liberty are delivered in fix packs periodically. This is a complete listing of all the fixes for Liberty...
Read more >
System Problem Detection by Mining Console Logs - CiteSeerX
write operation to a file fails silently (perhaps because the developers do not handle the error correctly), no single error message is ...
Read more >
UC Berkeley - eScholarship
can be used to supplement or even replace custom instrumentations. ... error correctly), no single error message is likely to indicate the failure....
Read more >
Malicious Manipulation in Service-Oriented Network, Software ...
QPDF [43], or in the case of manipulating academic papers, ... custom fonts depends on the system targeted, and the technique and evaluation ......
Read more >
A multi-scale feature selection approach for predicting benthic ...
Seafloor habitat maps are an important management tool used to delineate distinct regions of the seabed based on their biophysical properties.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found