diff --git a/umap/static/umap/js/modules/global.js b/umap/static/umap/js/modules/global.js index 82bd5c07..381b5497 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, RequestError, 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, RequestError, HTTPError, NOKError } diff --git a/umap/static/umap/js/modules/request.js b/umap/static/umap/js/modules/request.js index ec5c8d87..c9c5fc35 100644 --- a/umap/static/umap/js/modules/request.js +++ b/umap/static/umap/js/modules/request.js @@ -1,14 +1,17 @@ // Uses `L._`` from Leaflet.i18n which we cannot import as a module yet import { Evented, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js' -export class HTTPError extends Error { + +export class RequestError extends Error {} + +export class HTTPError extends RequestError { constructor(message) { super(message) this.name = this.constructor.name } } -export class NOKError extends Error { +export class NOKError extends RequestError { constructor(response) { super(response.status) this.response = response