aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/abstractworker/onerror/index.html
blob: b6ce35361eb5da2678cf5c6a39c16dc37e5952d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
title: AbstractWorker.onerror
slug: Web/API/AbstractWorker/onerror
translation_of: Web/API/AbstractWorker/onerror
---
<p>{{ APIRef("Web Workers API") }}</p>

<h2 id="Resumo">Resumo</h2>

<p>A propriedade <code><strong>AbstractWorker</strong></code><strong><code>.onerror</code></strong> da interface {{domxref("AbstractWorker")}} representa um {{domxref("EventHandler")}}, que é uma função a ser chamada quando o evento {{event("error")}} ocorre através de um balão de notificação {{domxref("Worker")}}.</p>

<h2 id="Sintaxe">Sintaxe</h2>

<pre class="syntaxbox">myWorker.onerror = function() { ... };</pre>

<h2 id="Exemplo">Exemplo</h2>

<p>O seguinte trecho de código mostra criação de um objeto <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker" title="The Worker interface represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread."><code>Worker</code></a> usando o construtor de <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker.Worker" title="The Worker() constructor creates a Worker that executes the script at the specified URL. This script must obey the same-origin policy."><code>Worker()</code></a> e criando um manipulador <code>onerror</code> no objeto resultante:</p>

<pre class="brush: js">var myWorker = new Worker("worker.js");

myWorker.onerror = function() {
  console.log('Há um erro com o seu worker!');
}</pre>

<h2 id="Especificações">Especificações</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Nenhuma mudança em {{SpecName("Web Workers")}}.</td>
  </tr>
  <tr>
   <td>{{SpecName('Web Workers', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}</td>
   <td>{{Spec2('Web Workers')}}</td>
   <td>Definição inicial.</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilidade_dos_Navegadores">Compatibilidade dos Navegadores</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Características</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{CompatChrome(4)}}</td>
   <td>{{CompatGeckoDesktop("1.9.1")}}</td>
   <td>10</td>
   <td>10.6</td>
   <td>4</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Características</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>4.4</td>
   <td>{{CompatGeckoMobile("1.9.1")}}</td>
   <td>1.0.1</td>
   <td>10</td>
   <td>11.5</td>
   <td>5.1</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="Veja_também">Veja também</h2>

<ul>
 <li>A interface {{domxref("AbstractWorker")}} a que pertence.</li>
</ul>