Revision 9ce969a7 ui/static/snf/js/utils.js

b/ui/static/snf/js/utils.js
47 47

  
48 48
        this.error = function() {
49 49
            var args = [2]; args.push.call(args, arguments);
50
            try {
51
                console.trace()
52
            } catch (err) {}
53 50
            this._log.apply(this, args);
54 51
        }
55 52

  
......
210 207
        }, 
211 208

  
212 209
        'abort': {},
213
        'parserror': {}
210
        'parserror': {},
211
        '413': {
212
            'title': "Account warning"
213
        }
214 214
    }
215 215
    
216 216
    synnefo.util.array_diff = function(arr1, arr2) {
......
285 285
        }
286 286
    }
287 287

  
288
    synnefo.util.parse_api_error = function(arguments) {
289
        arguments = arguments[0];
288
    synnefo.util.parse_api_error = function() {
289
        if (arguments.length == 1) { arguments = arguments[0] };
290 290

  
291 291
        var xhr = arguments[0];
292 292
        var error_message = arguments[1];
293 293
        var error_thrown = arguments[2];
294
        var ajax_settings = arguments.ajax || {};
295
        var call_settings = arguments.ajax ? arguments.ajax.error_params || {} : {};
296

  
294
        var ajax_settings = _.last(arguments) || {};
295
        var call_settings = ajax_settings.error_params || {};
297 296
        var json_data = undefined;
297

  
298
        var critical = ajax_settings.critical === undefined ? true : ajax_settings.critical;
299

  
298 300
        if (xhr.responseText) {
299 301
            try {
300 302
                json_data = JSON.parse(xhr.responseText)
......
315 317
            'message': 'Api error',
316 318
            'type': 'API',
317 319
            'allow_report': true,
318
            'fatal_error': ajax_settings.critical || false
320
            'fatal_error': ajax_settings.critical || false,
321
            'non_critical': !critical
319 322
        }
320 323

  
321 324
        var code = -1;
......
328 331
            defaults.non_critical = true;
329 332
            defaults.allow_report = false;
330 333
            defaults.allow_reload = false;
334
            error_message = "limit_error";
335
        }
336

  
337
        if (critical) {
338
            defaults.allow_report = true;
331 339
        }
332 340
        
333 341
        if (json_data) {
......
337 345
                error_message = obj.message;
338 346
            })
339 347
        }
340
        
348

  
341 349
        extra = {'URL': ajax_settings.url};
342 350
        options = {};
343 351
        options = _.extend(options, {'details': details, 'message': error_message, 'ns': module, 'extra_details': extra});
344 352
        options = _.extend(options, call_settings);
345 353
        options = _.extend(options, synnefo.i18n.API_ERROR_MESSAGES[error_message] || {});
354
        options = _.extend(options, synnefo.i18n.API_ERROR_MESSAGES[code] || {});
346 355
        
347 356
        if (window.ERROR_OVERRIDES && window.ERROR_OVERRIDES[options.message]) {
348 357
            options.message = window.ERROR_OVERRIDES[options.message];

Also available in: Unified diff