From 3f1070c90deef21e1507b2ff17a1a2d1f9cd91fb Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 30 Jan 2024 17:23:45 +0100 Subject: [PATCH] chore: rename NokError and fix init param --- umap/static/umap/js/modules/global.js | 4 ++-- umap/static/umap/js/modules/request.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/umap/static/umap/js/modules/global.js b/umap/static/umap/js/modules/global.js index f58b8c50..82bd5c07 100644 --- a/umap/static/umap/js/modules/global.js +++ b/umap/static/umap/js/modules/global.js @@ -1,9 +1,9 @@ import * as L from '../../vendors/leaflet/leaflet-src.esm.js' import URLs from './urls.js' -import { Request, ServerRequest, HTTPError, NokError } from './request.js' +import { Request, ServerRequest, HTTPError, NOKError } from './request.js' // Import modules and export them to the global scope. // For the not yet module-compatible JS out there. // Copy the leaflet module, it's expected by leaflet plugins to be writeable. window.L = { ...L } -window.umap = { URLs, Request, ServerRequest, HTTPError, NokError } +window.umap = { URLs, Request, ServerRequest, HTTPError, NOKError } diff --git a/umap/static/umap/js/modules/request.js b/umap/static/umap/js/modules/request.js index 5a06a27e..ec5c8d87 100644 --- a/umap/static/umap/js/modules/request.js +++ b/umap/static/umap/js/modules/request.js @@ -8,7 +8,7 @@ export class HTTPError extends Error { } } -export class NokError extends Error { +export class NOKError extends Error { constructor(response) { super(response.status) this.response = response @@ -37,7 +37,7 @@ const BaseRequest = Evented.extend({ } if (!response.ok) { this.fire('dataload', { id: id }) - throw new NokError(response.status) + throw new NOKError(response) } // TODO // - error handling @@ -68,7 +68,7 @@ export const Request = BaseRequest.extend({ ) return response } catch (error) { - if (error instanceof NokError) return this._onNok(error) + if (error instanceof NOKError) return this._onNOK(error) return this._onError(error) } }, @@ -85,7 +85,7 @@ export const Request = BaseRequest.extend({ this.ui.alert({ content: L._('Problem in the response'), level: 'error' }) }, - _onNok: function (error) { + _onNOK: function (error) { this._onError(error) return error.response }, @@ -145,7 +145,7 @@ export const ServerRequest = Request.extend({ return [{}, null, error] }, - _onNok: function (error) { + _onNOK: function (error) { if (error.status === 403) { this.ui.alert({ content: message || L._('Action not allowed :('),