@abaplint/runtime 2.13.32 → 2.13.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,11 +50,11 @@ class ABAPRegExp {
50
50
  }
51
51
  }
52
52
  else if (typeof r !== "string") {
53
- throw "getRegex(), unexpected input";
53
+ throw new Error("getRegex(), unexpected input");
54
54
  }
55
55
  r = ABAPRegExp.convert(r);
56
56
  if (r.length === 0 && options.all === true) {
57
- throw "getRegex(), zero length input";
57
+ throw new Error("getRegex(), zero length input");
58
58
  }
59
59
  return new RegExp(r, "m" + ignoreCase + allOccurrences);
60
60
  }
@@ -7,7 +7,7 @@ function contains(input) {
7
7
  || input.off !== undefined
8
8
  || input.len !== undefined
9
9
  || input.occ !== undefined) {
10
- throw "runtime, contains() todo";
10
+ throw new Error("runtime, contains() todo");
11
11
  }
12
12
  let ret = " ";
13
13
  if (input.regex) {
@@ -33,6 +33,7 @@ function escape(input) {
33
33
  val = val.replace(/'/g, "\\'");
34
34
  break;
35
35
  case 24: // e_json_string
36
+ val = val.replace(/\\/g, "\\\\");
36
37
  val = val.replace(/"/g, "\\\"");
37
38
  val = val.replace(/\n/g, "\\n");
38
39
  break;
@@ -6,11 +6,11 @@ const types_1 = require("../types");
6
6
  function find(input) {
7
7
  let val = typeof input.val === "string" ? input.val : input.val.get();
8
8
  if (input.len !== undefined) {
9
- throw "transpiler find(), todo len";
9
+ throw new Error("transpiler find(), todo len");
10
10
  }
11
11
  if (input.regex || input.pcre) {
12
12
  if (input.off !== undefined) {
13
- throw "transpiler find(), todo off regex";
13
+ throw new Error("transpiler find(), todo off regex");
14
14
  }
15
15
  const caseInput = typeof input.case === "string" ? input.case : input.case?.get();
16
16
  let regex = "";
@@ -6,7 +6,7 @@ function match(input) {
6
6
  const val = typeof input.val === "string" ? input.val : input.val.get();
7
7
  const regexInput = input.pcre || input.regex;
8
8
  if (regexInput === undefined) {
9
- throw "match() requires either regex or pcre parameter";
9
+ throw new Error("match() requires either regex or pcre parameter");
10
10
  }
11
11
  let reg = "";
12
12
  if (typeof regexInput === "string") {
@@ -4,7 +4,7 @@ exports.matches = matches;
4
4
  const types_1 = require("../types");
5
5
  function matches(input) {
6
6
  if (input.pcre === undefined && input.regex === undefined) {
7
- throw "matches(), todo";
7
+ throw new Error("matches(), todo");
8
8
  }
9
9
  const val = typeof input.val === "string" ? input.val : input.val.get();
10
10
  let reg = "";
@@ -14,7 +14,7 @@ function round(input) {
14
14
  const val = (0, _parse_1.parse)(input.val);
15
15
  const dec = (0, _parse_1.parse)(input.dec);
16
16
  if (dec !== 0) {
17
- throw "round(), todo, handle decimals";
17
+ throw new Error("round(), todo, handle decimals");
18
18
  }
19
19
  const ret = new types_1.Float();
20
20
  switch (mode) {
@@ -34,7 +34,7 @@ function round(input) {
34
34
  ret.set(Math.floor(val));
35
35
  break;
36
36
  default:
37
- throw "round(), unknown mode: " + mode;
37
+ throw new Error("round(), unknown mode: " + mode);
38
38
  }
39
39
  return ret;
40
40
  }
@@ -6,7 +6,7 @@ function append(input) {
6
6
  if (input.target instanceof types_1.FieldSymbol) {
7
7
  input.target = input.target.getPointer();
8
8
  if (input.target === undefined) {
9
- throw "Field symbol not assigned";
9
+ throw new Error("Field symbol not assigned");
10
10
  }
11
11
  }
12
12
  if (input.source instanceof types_1.FieldSymbol) {
@@ -15,7 +15,7 @@ function append(input) {
15
15
  if (input.target === undefined) {
16
16
  // short APPEND, use header field
17
17
  if (!(input.source instanceof types_1.Table)) {
18
- throw "APPEND, header, table";
18
+ throw new Error("APPEND, header, table");
19
19
  }
20
20
  input.source.append(input.source.getHeader());
21
21
  abap.builtin.sy.get().tabix.set(input.source.array().length);
@@ -20,7 +20,7 @@ function collect(source, target) {
20
20
  }
21
21
  }
22
22
  else {
23
- throw "COLLECT, no target specified";
23
+ throw new Error("COLLECT, no target specified");
24
24
  }
25
25
  }
26
26
  //# sourceMappingURL=collect.js.map
@@ -167,7 +167,7 @@ function createData(target, options) {
167
167
  target.assign(abap.Classes[className][typeName.toLowerCase().trimEnd()].clone());
168
168
  }
169
169
  else {
170
- throw "CREATE DATA, unknown type " + options.typeName;
170
+ throw new Error("CREATE DATA, unknown type " + options.typeName);
171
171
  }
172
172
  }
173
173
  }
@@ -33,7 +33,7 @@ async function deleteInternal(target, options) {
33
33
  }
34
34
  if (options?.to) {
35
35
  if (options?.from !== undefined || options?.where !== undefined) {
36
- throw "DeleteInternalTodo";
36
+ throw new Error("DeleteInternalTodo");
37
37
  }
38
38
  for (let i = 0; i < options.to.get(); i++) {
39
39
  target.deleteIndex(0);
@@ -39,7 +39,7 @@ function find(input, options) {
39
39
  s = abap_regex_1.ABAPRegExp.getRegex({ all: true, ...options });
40
40
  }
41
41
  else {
42
- throw "FIND, runtime, no input";
42
+ throw new Error("FIND, runtime, no input");
43
43
  }
44
44
  const matches = [];
45
45
  if (input instanceof types_1.Table) {
@@ -18,7 +18,7 @@ async function insertDatabase(table, options, context) {
18
18
  const columns = [];
19
19
  const values = [];
20
20
  if (options.values === undefined && options.table === undefined) {
21
- throw "insertDatabase, wrong input";
21
+ throw new Error("insertDatabase, wrong input");
22
22
  }
23
23
  if (options.table !== undefined) {
24
24
  let subrc = 0;
@@ -26,7 +26,7 @@ async function modifyDatabase(table, options, context) {
26
26
  }
27
27
  }
28
28
  else {
29
- throw "modifyDatabase todo";
29
+ throw new Error("modifyDatabase todo");
30
30
  }
31
31
  }
32
32
  //# sourceMappingURL=modify_database.js.map
@@ -22,7 +22,7 @@ function replace(input) {
22
22
  inp = input.of.getTrimEnd();
23
23
  }
24
24
  if (inp.length === 0 && input.all === true) {
25
- throw "REPLACE, zero length input";
25
+ throw new Error("REPLACE, zero length input");
26
26
  }
27
27
  found = temp.indexOf(inp) >= 0;
28
28
  inp = abap_regex_1.ABAPRegExp.escapeRegExp(inp);
@@ -40,7 +40,7 @@ function replace(input) {
40
40
  return;
41
41
  }
42
42
  else {
43
- throw "REPLACE, unexpected input";
43
+ throw new Error("REPLACE, unexpected input");
44
44
  }
45
45
  let rr = "";
46
46
  if (typeof input.with === "string") {
@@ -83,7 +83,7 @@ function sort(input, options) {
83
83
  }
84
84
  if (options?.by) {
85
85
  if (options.by.length === 0) {
86
- throw "SortByLengthZero";
86
+ throw new Error("SortByLengthZero");
87
87
  }
88
88
  input.sort((a, b) => {
89
89
  for (const c of options.by || []) {
@@ -61,7 +61,7 @@ function templateFormatting(source, options) {
61
61
  }
62
62
  if (options) {
63
63
  if (options.currency !== undefined) {
64
- throw "template formatting with currency not supported";
64
+ throw new Error("template formatting with currency not supported");
65
65
  }
66
66
  if (options.date === "iso") {
67
67
  text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2);
@@ -16,10 +16,10 @@ class Character {
16
16
  constructor(length, extra) {
17
17
  this.length = length || 1;
18
18
  if (typeof this.length === "object") {
19
- throw "Character, invalid length, object: " + JSON.stringify(this.length);
19
+ throw new Error("Character, invalid length, object: " + JSON.stringify(this.length));
20
20
  }
21
21
  else if (this.length <= 0) {
22
- throw "Character, invalid length, less than zero";
22
+ throw new Error("Character, invalid length, less than zero");
23
23
  }
24
24
  this.extra = extra;
25
25
  this.clear();
@@ -39,7 +39,7 @@ class DataReference {
39
39
  }
40
40
  get() {
41
41
  if (this.pointer === this) {
42
- throw "Cyclic data reference";
42
+ throw new Error("Cyclic data reference");
43
43
  }
44
44
  // @ts-ignore
45
45
  return this.pointer?.get();
@@ -7,11 +7,11 @@ const integer8_1 = require("./integer8");
7
7
  /*
8
8
  function getNumberParts(x: number) {
9
9
  if(isNaN(x)) {
10
- throw "Float NaN";
10
+ throw new Error("Float NaN";
11
11
  }
12
12
  const sig = x > 0 ? 1 : -1;
13
13
  if (!isFinite(x)) {
14
- throw "Float not finite";
14
+ throw new Error("Float not finite";
15
15
  }
16
16
  x = Math.abs(x);
17
17
  const exp = Math.floor(Math.log(x) * Math.LOG2E) - 52;
@@ -286,7 +286,7 @@ class HashedTable {
286
286
  }
287
287
  getHeader() {
288
288
  if (this.header === undefined) {
289
- throw "table, getHeader";
289
+ throw new Error("table, getHeader");
290
290
  }
291
291
  return this.header;
292
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.32",
3
+ "version": "2.13.34",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",