blob: 559f457cb27f303ddc5ced1c9ef460e3c1b00dba (
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
|
---
title: Error.prototype.message
slug: Web/JavaScript/Reference/Global_Objects/Error/message
tags:
- Error
- JavaScript
- Property
- Prototype
translation_of: Web/JavaScript/Reference/Global_Objects/Error/message
---
<div>{{JSRef}}</div>
<p>Die <code><strong>message</strong></code> Eigenschaft ist eine für Menschen lesbare Beschreibung von Errors.</p>
<h2 id="Beschreibung">Beschreibung</h2>
<p>Diese Eigenschaft enthält eine knappe Beschreibung des Errors, wenn eine verfügbar ist oder gesetzt wird. Zum Beispiel setzt <a href="/de/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> diese Eigenschaft sehr oft ein. Die <code>message</code> Eigenschaft kombiniert mit der {{jsxref("Error.prototype.name", "name")}} Eigenschaft werden in der {{jsxref("Error.prototype.toString()")}} Methode eingesetzt, um eine String-Repräsentation des Errors zu erstellen.</p>
<p>Der Standardwert für die <code>message</code> Eigenschaft ist ein leerer String, jedoch kann diese von einer Instanz überschrieben werden, indem der erste Parameter des {{jsxref("Error", "Error Konstruktors")}} gesetzt wird.</p>
<h2 id="Beispiele">Beispiele</h2>
<h3 id="Einen_benutzerdefinierten_Fehler_erzeugen">Einen benutzerdefinierten Fehler erzeugen</h3>
<pre class="brush: js">var e = new Error('Falsches Eingabeformat');
// e.message ist 'Falsches Eingabeformat'
throw e;
</pre>
<h2 id="Spezifikationen">Spezifikationen</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Spezifikation</th>
<th scope="col">Status</th>
<th scope="col">Kommentar</th>
</tr>
<tr>
<td>{{SpecName('ES1')}}</td>
<td>{{Spec2('ES1')}}</td>
<td>Initiale Definition.</td>
</tr>
<tr>
<td>{{SpecName('ES5.1', '#sec-15.11.4.3', 'Error.prototype.message')}}</td>
<td>{{Spec2('ES5.1')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('ES6', '#sec-error.prototype.message', 'Error.prototype.message')}}</td>
<td>{{Spec2('ES6')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-error.prototype.message', 'Error.prototype.message')}}</td>
<td>{{Spec2('ESDraft')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Browserkompatibilität">Browserkompatibilität</h2>
<div>
<p>{{Compat("javascript.builtins.Error.message")}}</p>
</div>
<h2 id="Siehe_auch">Siehe auch</h2>
<ul>
<li>{{jsxref("Error.prototype.name")}}</li>
<li>{{jsxref("Error.prototype.toString()")}}</li>
</ul>
|