Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
Loading items
Show changes
Commits on Source (4)
<a name="v3.43.0"></a>
## [v3.43.0] - 2023-04-07
### Add Features
- new DataFetchError
<a name="v3.42.1"></a>
## [v3.42.1] - 2023-04-03
### Bug Fixes
......@@ -581,6 +587,7 @@
<a name="1.8.0"></a>
## 1.8.0 - 2021-08-15
[v3.43.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.42.1...v3.43.0
[v3.42.1]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.42.0...v3.42.1
[v3.42.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.41.0...v3.42.0
[v3.41.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.40.0...v3.41.0
......
{
"name": "@schukai/monster",
"version": "3.42.0",
"version": "3.42.1",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......
......@@ -9,6 +9,7 @@ import { internalSymbol, instanceSymbol } from "../../../constants.mjs";
import {isObject, isFunction} from "../../../types/is.mjs";
import {Server} from "../server.mjs";
import {WriteError} from "./restapi/writeerror.mjs";
import {DataFetchError} from "./restapi/data-fetch-error.mjs";
export {RestAPI};
......@@ -188,7 +189,7 @@ function fetchData(init, key, callback) {
const acceptedStatus = self.getOption(`${key}.acceptedStatus`, [200]);
if (acceptedStatus.indexOf(resp.status) === -1) {
throw Error(`the data cannot be ${key} (response ${resp.status})`);
throw new DataFetchError(`the response does not contain a accepted status (actual: ${resp.status}).`, response);
}
return resp.text();
......@@ -205,7 +206,7 @@ function fetchData(init, key, callback) {
body = `${body.substring(0, 97)}...`;
}
throw new Error(`the response does not contain a valid json (actual: ${body}).`);
throw new DataFetchError(`the response does not contain a valid json (actual: ${body}).`, response);
}
if (callback && isFunction(callback)) {
......
/**
* Copyright schukai GmbH and contributors 2023. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import { internalSymbol, instanceSymbol } from "../../../../constants.mjs";
export { DataFetchError };
/**
* Error message for API requests
*
* @license AGPLv3
* @since 3.43.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource.Server.RestAPI
* @summary the error is thrown by the rest api in case of error
*/
class DataFetchError extends Error {
/**
*
* @param {string} message
* @param {Response} response
*/
constructor(message, response) {
super(message);
this[internalSymbol] = {
response: response
};
}
/**
* This method is called by the `instanceof` operator.
* @returns {symbol}
* @since 2.1.0
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/data/datasource/server/restapi/datafetcherror@@instance");
}
/**
* @return {Response}
*/
getResponse() {
return this[internalSymbol]["response"];
}
}
......@@ -142,7 +142,7 @@ function getMonsterVersion() {
}
/** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.42.0");
monsterVersion = new Version("3.42.1");
return monsterVersion;
}
{
"name": "monster",
"version": "3.42.0",
"version": "3.42.1",
"description": "monster",
"repository": {
"type": "git",
......
......@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion
/** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.42.0")
monsterVersion = new Version("3.42.1")
let m = getMonsterVersion();
......
{"version":"3.42.1"}
{"version":"3.43.0"}