~noskcaj/ubuntu/trusty/gnome-documents/3.10.2

« back to all changes in this revision

Viewing changes to src/error.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-06-29 13:16:35 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120629131635-tkocc51xk4c37a39
Tags: 0.5.3-0ubuntu1
* New upstream release.
* debian/control.in:
  - Bump minimum GTK
  - Build-depend on libzapojit-dev

Show diffs side-by-side

added added

removed removed

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