Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit 3aa36fd

Browse files
author
steven.roulleau
committed
fix(error): change handle error
1 parent ee51155 commit 3aa36fd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

examples/non-version-specific/handle_errors.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
<div id="editor" touch-action="none"></div>
2424
</div>
2525
<script>
26-
var editorElement = document.getElementById('editor');
26+
const editorElement = document.getElementById('editor');
2727

28-
editorElement.addEventListener('error', function (evt) {
29-
document.querySelector('#result').innerText = JSON.stringify(evt.detail);
28+
editorElement.addEventListener('error', (evt) => {
29+
if(evt.detail && evt.detail.type !== 'close') {
30+
document.querySelector('#result').innerText = JSON.stringify(evt.detail);
31+
}
3032
});
3133

3234
/**

src/Editor.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,20 @@ function recognizerCallback(editor, error, model, ...events) {
189189
} else if (err.message === 'Session is too old. Max Session Duration Reached' ||
190190
(err.code && err.code === 'session.too.old')) {
191191
editorRef.error.innerText = Constants.Error.TOO_OLD;
192-
} else if ((err.message || err.code === 1006) && editorRef.error.style.display === 'none') {
192+
} else if ((err.code === 1006 || err.code === 1000) && editorRef.error.style.display === 'none') {
193193
editorRef.error.innerText = Constants.Error.NOT_REACHABLE;
194194
}
195-
if ((editorRef.error.innerText === Constants.Error.TOO_OLD || err.code === 1000 || err.reason === 'CLOSE_RECOGNIZER') && RecognizerContext.canReconnect(editor.recognizerContext)) {
195+
if ((editorRef.error.innerText === Constants.Error.TOO_OLD || err.reason === 'CLOSE_RECOGNIZER') && RecognizerContext.canReconnect(editor.recognizerContext)) {
196196
logger.info('Reconnection is available', err.stack || err);
197197
editorRef.error.style.display = 'none';
198198
} else {
199199
editorRef.error.style.display = 'initial';
200200
triggerCallbacks(editor, err, Constants.EventType.ERROR, ...types);
201201
}
202202
} else {
203+
if (editorRef.error.style.display === 'initial') {
204+
editorRef.error.style.display = 'none';
205+
}
203206
manageRecognizedModel(editorRef, res, ...[...events, ...types].filter((el, i, a) => i === a.indexOf(el))); // Remove duplicate events
204207
}
205208
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy