@indra.ai/deva 1.5.63 → 1.6.1

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.
Files changed (2) hide show
  1. package/index.js +74 -63
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -98,7 +98,7 @@ class Deva {
98
98
  });
99
99
  }
100
100
  catch (e) {
101
- return this.error(e, false, reject); // trigger the this.error for errors
101
+ return this.err(e, false, reject); // trigger the this.err for errors
102
102
  }
103
103
  finally {
104
104
  return resolve(); // when the configuration is complete then return an empty resolve.
@@ -133,7 +133,7 @@ class Deva {
133
133
  }
134
134
  }
135
135
  catch (e) {
136
- return this.error(e, false, reject); // pass errors to this.error
136
+ return this.err(e, false, reject); // pass errors to this.err
137
137
  }
138
138
  finally {
139
139
  return resolve(); // resolve the function after everything is done.
@@ -161,7 +161,7 @@ class Deva {
161
161
  return resolve();
162
162
  }
163
163
  catch (e) {
164
- return this.error(e, false, reject);
164
+ return this.err(e, false, reject);
165
165
  }
166
166
  });
167
167
  }
@@ -225,7 +225,7 @@ class Deva {
225
225
  return data; // return the security feature
226
226
  } catch (e) {
227
227
  this.state('catch', key);
228
- return this.error(e);
228
+ return this.err(e);
229
229
  }
230
230
  }
231
231
 
@@ -261,7 +261,7 @@ class Deva {
261
261
  this.state('resolve', 'client');
262
262
  return resolve();
263
263
  } catch (e) {
264
- return this.error(e, false, reject);
264
+ return this.err(e, false, reject);
265
265
  }
266
266
  }
267
267
 
@@ -300,7 +300,7 @@ class Deva {
300
300
  }
301
301
  } catch (e) {
302
302
  this.state('catch', `${feature}:${_id.uid}`);
303
- return this.error(e, feature, reject); // run error handling if an error is caught
303
+ return this.err(e, feature, reject); // run error handling if an error is caught
304
304
  }
305
305
  }
306
306
 
@@ -568,7 +568,7 @@ class Deva {
568
568
  return resolve(this.client()); // resolve an empty pr
569
569
  } catch (e) {
570
570
  this.state('catch', 'Done');
571
- return this.error(e, false, reject);
571
+ return this.err(e, false, reject);
572
572
  }
573
573
  }
574
574
 
@@ -723,7 +723,7 @@ class Deva {
723
723
  }
724
724
  catch(e) {
725
725
  this.state('catch', 'question');
726
- return this.error(e); // if a overall error happens this witll call this.error
726
+ return this.err(e); // if a overall error happens this witll call this.err
727
727
  }
728
728
  });
729
729
  }
@@ -788,11 +788,11 @@ class Deva {
788
788
  return this.finish(packet, resolve); // resolve the packet to the caller.
789
789
  }).catch(err => { // catch any errors in the method
790
790
  this.state('catch', `answer:${method}:${id.uid}`); // set the state reject answer
791
- return this.error(err, packet, reject); // return this.error with err, packet, reject
791
+ return this.err(err, packet, reject); // return this.err with err, packet, reject
792
792
  });
793
793
  } catch (e) {
794
794
  this.state('catch', `answer:${method}:${id.uid}`);
795
- return this.error(e, packet, reject);
795
+ return this.err(e, packet, reject);
796
796
  }
797
797
  }
798
798
 
@@ -864,13 +864,13 @@ class Deva {
864
864
  }).catch(err => {
865
865
  this.talk(`${agent.key}:ask:${packet.id.uid}`, {error:err});
866
866
  this.state('catch', `ask:${method}:${packet.id.uid}`);
867
- return this.error(err, packet);
867
+ return this.err(err, packet);
868
868
  })
869
869
  }
870
870
  catch (e) {
871
871
  this.state('catch', `ask:${method}:${packet.id.uid}`);
872
872
  this.talk(`${agent.key}:ask:${packet.id.uid}`, {error:e});
873
- return this.error(e, packet)
873
+ return this.err(e, packet)
874
874
  }
875
875
  // now when we ask the meta params[0] should be the method
876
876
  }
@@ -975,7 +975,7 @@ class Deva {
975
975
  return hasOnInit ? this.onInit(data, resolve) : this.start(data, resolve);
976
976
  }).catch(err => {
977
977
  this.state('catch', `init:${data.id.uid}`);
978
- return this.error(err, client, reject);
978
+ return this.err(err, client, reject);
979
979
  });
980
980
  });
981
981
  }
@@ -1301,7 +1301,7 @@ class Deva {
1301
1301
  this.talk(config.events.state, data); // broadcasat the state event
1302
1302
  return data;
1303
1303
  } catch (e) { // catch any errors
1304
- return this.error(e); // return if an error happens
1304
+ return this.err(e); // return if an error happens
1305
1305
  }
1306
1306
  }
1307
1307
 
@@ -1361,7 +1361,7 @@ class Deva {
1361
1361
  return data;
1362
1362
  } catch (e) {
1363
1363
  this.state('catch', `zone:${value}:${id.uid}`);
1364
- return this.error(e, value);
1364
+ return this.err(e, value);
1365
1365
  }
1366
1366
  }
1367
1367
 
@@ -1428,7 +1428,7 @@ class Deva {
1428
1428
  return data;
1429
1429
  } catch (e) { // catch any errors that occur
1430
1430
  this.state('catch', `action:${value}:${id.uid}`);
1431
- return this.error(e); // return error on error catch
1431
+ return this.err(e); // return error on error catch
1432
1432
  }
1433
1433
  }
1434
1434
 
@@ -1489,7 +1489,7 @@ class Deva {
1489
1489
  return data;
1490
1490
  } catch (e) { // catch any errors
1491
1491
  this.state('catch', `feature:${value}:${id.uid}`);
1492
- return this.error(e); // retun this.error when an error is caught.
1492
+ return this.err(e); // retun this.err when an error is caught.
1493
1493
  }
1494
1494
  }
1495
1495
 
@@ -1553,7 +1553,7 @@ class Deva {
1553
1553
  return data;
1554
1554
  } catch (e) {
1555
1555
  this.state('catch', `context:${value}:${id.uid}`);
1556
- return this.error(e, value);
1556
+ return this.err(e, value);
1557
1557
  }
1558
1558
  }
1559
1559
 
@@ -1637,52 +1637,15 @@ class Deva {
1637
1637
 
1638
1638
  /**************
1639
1639
  func: error
1640
- params:
1641
- - err: The error to process
1642
- - data: Any additional data associated with the error
1643
- - reject: An associated promise reject if the caller requires.
1644
- describe:
1645
- The error function provides the consistent error manage of the system.
1646
- usage: this.error(err, data, reject);
1640
+ params: none
1641
+ describe: basic error features available in a Deva.
1642
+ usage: this.error()
1647
1643
  ***************/
1648
- error(err,packet,reject=false) {
1649
- const id = this.lib.uid();
1650
- this.zone('error', id.uid);
1651
- this.feature('error', id.uid);
1652
-
1653
- const agent = this.agent();
1654
- const client = this.client();
1655
-
1656
- this.action('error', id.uid);
1657
- const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
1658
-
1659
- const data = {
1660
- id,
1661
- key: 'error',
1662
- value: agent.key,
1663
- agent,
1664
- client,
1665
- error: {
1666
- name: err.name,
1667
- message: err.message,
1668
- stack: err.stack,
1669
- },
1670
- packet,
1671
- created: Date.now(),
1672
- }
1673
- data.md5 = this.lib.hash(data);
1674
- data.sha256 = this.lib.hash(data, 'sha256');
1675
- data.sha512 = this.lib.hash(data, 'sha512');
1676
-
1677
- this.talk(config.events.error, this.lib.copy(data));
1678
-
1679
- this.state('return', `error:${id.uid}`);
1680
- this.state('error', id.uid);
1681
- this.context('error', id.uid);
1682
- if (hasOnError) return this.onError(err, packet, reject);
1683
- else return reject ? reject(err) : Promise.reject(err);
1644
+ error() {
1645
+ return this._getFeature('error', this._error);
1684
1646
  }
1685
1647
 
1648
+
1686
1649
  /**************
1687
1650
  func: vector
1688
1651
  params: none
@@ -1895,7 +1858,7 @@ class Deva {
1895
1858
  this.state('unload', key)
1896
1859
  return resolve(`${this._states.unload}:${key}`);
1897
1860
  } catch (e) {
1898
- return this.error(e, this.devas[key], reject)
1861
+ return this.err(e, this.devas[key], reject)
1899
1862
  }
1900
1863
  });
1901
1864
  }
@@ -2054,7 +2017,7 @@ class Deva {
2054
2017
  }
2055
2018
  catch(e) {
2056
2019
  this.state('catch', `help:${id.uid}`);
2057
- return this.error(e, msg, reject);
2020
+ return this.err(e, msg, reject);
2058
2021
  }
2059
2022
  finally {
2060
2023
  this.state('return', `help:${id.uid}`);
@@ -2062,5 +2025,53 @@ class Deva {
2062
2025
  }
2063
2026
  });
2064
2027
  }
2028
+
2029
+ /**************
2030
+ func: err
2031
+ params:
2032
+ - err: The error to process
2033
+ - data: Any additional data associated with the error
2034
+ - reject: An associated promise reject if the caller requires.
2035
+ describe:
2036
+ The err function provides the consistent error manage of the system.
2037
+ usage: this.err(err, data, reject);
2038
+ ***************/
2039
+ err(err,packet,reject=false) {
2040
+ const id = this.lib.uid();
2041
+ this.zone('error', id.uid);
2042
+ this.feature('error', id.uid);
2043
+
2044
+ const agent = this.agent();
2045
+ const client = this.client();
2046
+
2047
+ this.action('error', id.uid);
2048
+ const hasOnError = this.onError && typeof this.onError === 'function' ? true : false;
2049
+
2050
+ const data = {
2051
+ id,
2052
+ key: 'error',
2053
+ value: agent.key,
2054
+ agent,
2055
+ client,
2056
+ error: {
2057
+ name: err.name,
2058
+ message: err.message,
2059
+ stack: err.stack,
2060
+ },
2061
+ packet,
2062
+ created: Date.now(),
2063
+ }
2064
+ data.md5 = this.lib.hash(data);
2065
+ data.sha256 = this.lib.hash(data, 'sha256');
2066
+ data.sha512 = this.lib.hash(data, 'sha512');
2067
+
2068
+ this.talk(config.events.error, this.lib.copy(data));
2069
+
2070
+ this.state('return', `error:${id.uid}`);
2071
+ this.state('error', id.uid);
2072
+ this.context('error', id.uid);
2073
+ if (hasOnError) return this.onError(err, packet, reject);
2074
+ else return reject ? reject(err) : Promise.reject(err);
2075
+ }
2065
2076
  }
2066
2077
  export default Deva;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "9f0bc743-d720-4320-832e-cf5edc3b7cf",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.5.63",
4
+ "version": "1.6.1",
5
5
  "description": "The Deva Core",
6
6
  "main": "index.js",
7
7
  "copyright": "(c)2025 Quinn A Michaels; All rights reserved.",