Compare Revisions

Downloads.jsm

Revision 419017:

Revision 419017 by P.A. on

Revision 419019:

Revision 419019 by P.A. on

Title:
Downloads.jsm
Downloads.jsm
Slug:
Mozilla/JavaScript_code_modules/Downloads.jsm
Mozilla/JavaScript_code_modules/Downloads.jsm
Content:

Revision 419017
Revision 419019
tt51          </td>
52        </tr>
53      </tbody>
54    </table>
55    <h2 id="Properties">
56      Properties
57    </h2>
58    <table class="standard-table" style="width: auto;">
59      <tbody>
60        <tr>
61          <td class="header">
62            Attribute
63          </td>
64          <td class="header">
65            Type
66          </td>
67          <td class="header">
68            Description
69          </td>
70        </tr>
71        <tr>
72          <td>
73            <code>Error</code> <span class="inlineIndicator readO
 >nly readOnlyInline" title="This value may not be changed.">Read o
 >nly</span>
74          </td>
75          <td>
76            <a href="/en-US/docs/JavaScript/Guide/Working_with_Ob
 >jects#Using_a_constructor_function" title="/en-US/docs/JavaScript
 >/Guide/Working_with_Objects#Using_a_constructor_function"><code>C
 >onstructor</code></a>
77          </td>
78          <td>
79            Constructor for a <a href="/en-US/docs/Mozilla/JavaSc
 >ript_code_modules/Downloads.jsm/DownloadError" title="/en-US/docs
 >/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError"><co
 >de>DownloadError</code></a> object. When you catch an exception d
 >uring a download, you can use this to verify if <code>ex instance
 >of Downloads.Error</code>, before reading the exception propertie
 >s with the error details. Example (using <a href="/en-US/docs/Moz
 >illa/JavaScript_code_modules/Task.jsm" title="/en-US/docs/Mozilla
 >/JavaScript_code_modules/Task.jsm"><code>Task.jsm</code></a>):
80            <pre class="brush: js">
81try {
82  yield Downloads.simpleDownload(sourceUri, targetFile);
83} catch (ex if ex instanceof Downloads.Error &amp;&amp; ex.becaus
 >eTargetFailed) {
84  console.log("Unable to write to the target file, ignoring the e
 >rror.");
85}
86</pre>

Back to History