From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/idbdatabase/onerror/index.html | 151 ++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 files/fr/web/api/idbdatabase/onerror/index.html (limited to 'files/fr/web/api/idbdatabase/onerror') diff --git a/files/fr/web/api/idbdatabase/onerror/index.html b/files/fr/web/api/idbdatabase/onerror/index.html new file mode 100644 index 0000000000..fbfb5efab3 --- /dev/null +++ b/files/fr/web/api/idbdatabase/onerror/index.html @@ -0,0 +1,151 @@ +--- +title: IDBDatabase.onerror +slug: Web/API/IDBDatabase/onerror +tags: + - API + - IndexedDB + - Propriété + - Reference +translation_of: Web/API/IDBDatabase/onerror +--- +
{{APIRef("IndexedDB")}}
+ +

Le gestionnaire d'événement onerror, rattaché à  l'interface IDBDatabase, s’exécute au déclenchement de l'événement error qui se produit lorsque la connexion à la base de donnée échoue.

+ +

{{AvailableInWorkers}}

+ +

Syntaxe

+ +
db.onerror = function() { ... }
+ +

Exemple

+ +

Dans cet exemple, on illustre un gestionnaire d'événement {{domxref("IDBOpenDBRequest.onupgradeneeded")}} dans lequel on ajoute un magasin d'objet et les deux gestionnaires d'événements onerror et onabort afin de gérer les cas d'échec de la connexion.

+ +
DBOpenRequest.onupgradeneeded = function(event) {
+  var db = event.target.result;
+
+  db.onerror = function() {
+    note.innerHTML += '<li>Erreur du chargement de la base de données.</li>';
+  };
+
+  db.onabort = function() {
+    note.innerHTML += '<li>L\'ouverture de la connexion à été annulé!</li>';
+  };
+
+  // Ajoute un magasin d'objet à la base de données
+
+  var objectStore = db.createObjectStore("toDoList", { keyPath: "taskTitle" });
+
+  // Définition des index
+
+  objectStore.createIndex("hours", "hours", { unique: false });
+  objectStore.createIndex("minutes", "minutes", { unique: false });
+  objectStore.createIndex("day", "day", { unique: false });
+  objectStore.createIndex("month", "month", { unique: false });
+  objectStore.createIndex("year", "year", { unique: false });
+
+  objectStore.createIndex("notified", "notified", { unique: false });
+
+  note.innerHTML += '<li>Le magasin d\'objets à été ajouté.</li>';
+};
+ +

Spécifications

+ + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('IndexedDB', '#widl-IDBDatabase-onerror', 'onerror')}}{{Spec2('IndexedDB')}} 
+ +

Compatibilité des navigateurs

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Support simple23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, en partie157.1
Disponible via les web workers{{CompatVersionUnknown}}{{CompatGeckoMobile("37.0")}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Support simple4.4{{CompatGeckoMobile("22.0")}}1.0.110228
Disponible via les web workers{{CompatVersionUnknown}}{{CompatGeckoMobile("37.0")}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}
+
+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf