loleaflet/reference.html              |   32 ++++++++++++++++++++++++++++++++
 loleaflet/src/core/Socket.js          |    8 ++++----
 loleaflet/src/layer/tile/TileLayer.js |   13 ++++++++++---
 3 files changed, 46 insertions(+), 7 deletions(-)

New commits:
commit 43417659ad4e59a6f854093c92c11698308ca40b
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Thu Jan 14 21:28:10 2016 +0100

    loleaflet: Implement 'id' for errors.
    
    Most of the errors are not interesting for the user (in the sense that they
    couldn't do anything about them anyway), for those return just a general
    'internal error'; details are still available through the 'cmd' and 'kind'.
    
    The rest have their own 'id'.

diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index dfe1736..7ac486e 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2046,6 +2046,12 @@ unexpected behaviour.</h4>
                <th>description</th>
        </tr>
        <tr>
+               <td><code><b>id</b></code></td>
+               <td><code>Number</code></td>
+               <td>Identificator of the error that can be used as indication
+               of error message to present to the user.</td>
+       </tr>
+       <tr>
                <td><code><b>msg</b></code></td>
                <td><code>String</code></td>
                <td>If present, the error message.</td>
@@ -2062,6 +2068,32 @@ unexpected behaviour.</h4>
        </tr>
 </table>
 
+The <code>id</code> property of ErrorEvent can have the following values:
+
+<table data-id='events'>
+       <tr>
+               <th>value</th>
+               <th>description</th>
+       </tr>
+       <tr>
+               <td><code><b>1</b></code></td>
+               <td>Internal error. Things still may work to some extent, but
+               the session becomes unreliable.</td>
+       </tr>
+       <tr>
+               <td><code><b>2</b></code></td>
+               <td>Document couldn't be loaded.</td>
+       </tr>
+       <tr>
+               <td><code><b>3</b></code></td>
+               <td>Socket connection error.</td>
+       </tr>
+       <tr>
+               <td><code><b>4</b></code></td>
+               <td>Socket connection was closed.</td>
+       </tr>
+</table>
+
 <h3 id="invalidatepreview-event">InvalidatePreviewEvent</h3>
 <p>LOLeaflet specific events.</p>
 
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 433a10f..f4e01e7 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -6,13 +6,13 @@ L.Socket = L.Class.extend({
        ProtocolVersionNumber: '0.1',
 
        initialize: function (map) {
+               this._map = map;
                try {
                        this.socket = new WebSocket(map.options.server);
                } catch (e) {
-                       this.fire('error', {msg: 'Socket connection error'});
+                       this._map.fire('error', {msg: 'Socket connection 
error', cmd: 'socket', kind: 'failed', id: 3});
                        return null;
                }
-               this._map = map;
                this._msgQueue = [];
                this.socket.onerror = L.bind(this._onSocketError, map);
                this.socket.onclose = L.bind(this._onSocketClose, map);
@@ -175,11 +175,11 @@ L.Socket = L.Class.extend({
        },
 
        _onSocketError: function () {
-               this.fire('error', {msg: 'Socket connection error'});
+               this._map.fire('error', {msg: 'Socket connection error', cmd: 
'socket', kind: 'failed', id: 3});
        },
 
        _onSocketClose: function () {
-               this.fire('error', {msg: 'Socket connection closed'});
+               this._map.fire('error', {msg: 'Socket connection closed', cmd: 
'socket', kind: 'closed', id: 4});
        },
 
        parseServerCmd: function (msg) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 04fe59c..4a2f2b8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -354,7 +354,14 @@ L.TileLayer = L.GridLayer.extend({
 
        _onErrorMsg: function (textMsg) {
                var command = this._map._socket.parseServerCmd(textMsg);
-               this._map.fire('error', {cmd: command.errorCmd, kind: 
command.errorKind});
+
+               // let's provide some convenience error codes for the UI
+               var errorId = 1; // internal error
+               if (command.errorCmd === 'load') {
+                   errorId = 2; // document cannot be loaded
+               }
+
+               this._map.fire('error', {cmd: command.errorCmd, kind: 
command.errorKind, id: errorId});
        },
 
        _onGetChildIdMsg: function (textMsg) {
@@ -812,7 +819,7 @@ L.TileLayer = L.GridLayer.extend({
                        }
                        this._graphicMarker = 
L.rectangle(this._graphicSelection, {fill: false});
                        if (!this._graphicMarker) {
-                               this._map.fire('error', {msg: 'Graphic marker 
initialization'});
+                               this._map.fire('error', {msg: 'Graphic marker 
initialization', cmd: 'marker', kind: 'failed', id: 1});
                                return;
                        }
                        this._graphicMarker.editing.enable();
@@ -833,7 +840,7 @@ L.TileLayer = L.GridLayer.extend({
                        }
                        this._cellCursorMarker = L.rectangle(this._cellCursor, 
{fill: false, color: '#000000', weight: 2});
                        if (!this._cellCursorMarker) {
-                               this._map.fire('error', {msg: 'Cell Cursor 
marker initialization'});
+                               this._map.fire('error', {msg: 'Cell Cursor 
marker initialization', cmd: 'cellCursor', kind: 'failed', id: 1});
                                return;
                        }
                        this._map.addLayer(this._cellCursorMarker);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to