chore: make all request errors inherit the same parent class
This commit is contained in:
parent
6b5ecac9c6
commit
325880f86f
2 changed files with 7 additions and 4 deletions
|
@ -1,9 +1,9 @@
|
||||||
import * as L from '../../vendors/leaflet/leaflet-src.esm.js'
|
import * as L from '../../vendors/leaflet/leaflet-src.esm.js'
|
||||||
import URLs from './urls.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.
|
// Import modules and export them to the global scope.
|
||||||
// For the not yet module-compatible JS out there.
|
// For the not yet module-compatible JS out there.
|
||||||
|
|
||||||
// Copy the leaflet module, it's expected by leaflet plugins to be writeable.
|
// Copy the leaflet module, it's expected by leaflet plugins to be writeable.
|
||||||
window.L = { ...L }
|
window.L = { ...L }
|
||||||
window.umap = { URLs, Request, ServerRequest, HTTPError, NOKError }
|
window.umap = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError }
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
// Uses `L._`` from Leaflet.i18n which we cannot import as a module yet
|
// Uses `L._`` from Leaflet.i18n which we cannot import as a module yet
|
||||||
import { Evented, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js'
|
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) {
|
constructor(message) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = this.constructor.name
|
this.name = this.constructor.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NOKError extends Error {
|
export class NOKError extends RequestError {
|
||||||
constructor(response) {
|
constructor(response) {
|
||||||
super(response.status)
|
super(response.status)
|
||||||
this.response = response
|
this.response = response
|
||||||
|
|
Loading…
Reference in a new issue