Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Exception/Http/HttpError.js')
-rw-r--r--src/Exception/Http/HttpError.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Exception/Http/HttpError.js b/src/Exception/Http/HttpError.js
new file mode 100644
index 0000000..e86dfed
--- /dev/null
+++ b/src/Exception/Http/HttpError.js
@@ -0,0 +1,42 @@
+export default class HttpError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'HttpError';
+ }
+
+ /**
+ * @returns {Response}
+ */
+ get response() {
+ return this._response;
+ }
+
+ /**
+ * @returns {Number}
+ */
+ get status() {
+ return this._status;
+ }
+
+ /**
+ *
+ * @param {Response} response
+ * @param {String} statusText
+ */
+ constructor(response, statusText = '') {
+ let message = `HTTP ${response.status}`;
+
+ if(statusText.length !== 0) {
+ message += ` - ${statusText}`;
+ } else if(response.statusText.length !== 0) {
+ message += ` - ${response.statusText}`;
+ }
+
+ super(message);
+ this._response = response;
+ this._status = response.status;
+ }
+} \ No newline at end of file