22
22
const Lang = imports.lang;
23
23
const Signals = imports.signals;
25
const Gio = imports.gi.Gio;
25
26
const _ = imports.gettext.gettext;
27
function ErrorHandler() {
28
const ErrorHandler = new Lang.Class({
31
ErrorHandler.prototype = {
32
31
_init: function() {
35
34
addLoadError: function(doc, exception) {
35
if (exception.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
36
38
// Translators: %s is the title of a document
37
39
let message = _("Unable to load \"%s\" for preview").format(doc.name);
39
// FIXME: we need support for error codes in GJS
40
if (exception.toString().indexOf('Operation was cancelled') != -1)
43
log('Error caught: ' + message + ' - ' + exception.message);
45
40
this.emit('load-error', message, exception);
48
43
addQueryError: function(exception) {
44
if (exception.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
49
47
let message = _("Unable to fetch the list of documents");
51
// FIXME: we need support for error codes in GJS
52
if (exception.toString().indexOf('Operation was cancelled') != -1)
55
48
this.emit('query-error', message, exception);
58
51
Signals.addSignalMethods(ErrorHandler.prototype);