Exception handling: Difference between revisions

Content deleted Content added
Add: journal, title. | Use this tool. Report bugs. | #UCB_Gadget
m In user interfaces: {{codett}}
 
Line 48:
 
For example, in [[Vue.js]], a component would catch errors by implementing <code>errorCaptured</code>
{{pre|
<syntaxhighlight lang="vue">
{{codett|2=js|1=Vue.component('parent', {}}
{{codett|2=vue |template: '<div><slot></slot></div>',}}
{{codett|2=js|1=errorCaptured: (err, vm, info) => alert('An error occurred');}}
})
{{codett|2=js|1=Vue.component('child', {}}
{{codett|2=vue |template: '<div>{{((}} cause_error() {{))}}</div>'}}
})
}}
</syntaxhighlight>When used like this in markup:<syntaxhighlight lang="html">
When used like this in markup:
<syntaxhighlight lang="vuehtml">
<parent>
<child></child>
</parent>
</syntaxhighlight>
</syntaxhighlight>The error produced by the child component is caught and handled by the parent component.<ref>{{Cite web|url=https://catchjs.com/Docs/Vue|title=Error handling with Vue.js|website=CatchJS|access-date=2018-12-10}}</ref>
 
==See also==