Skip to content

Commit 684bde1

Browse files
v1.37.1 (#602)
Co-authored-by: Allan RIbeiro <[email protected]>
1 parent eaa89e4 commit 684bde1

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/apps-engine",
3-
"version": "1.37.0",
3+
"version": "1.37.1",
44
"description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.",
55
"main": "index",
66
"typings": "index",

src/definition/exceptions/AppsEngineException.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,19 @@
1111
* that a user cannot perform some action, e.g.
1212
* join a room
1313
*/
14-
export class AppsEngineException extends Error {}
14+
export class AppsEngineException extends Error {
15+
public name = 'AppsEngineException';
16+
public message: string;
17+
18+
constructor(message?: string) {
19+
super();
20+
this.message = message;
21+
}
22+
23+
public getErrorInfo() {
24+
return {
25+
name: this.name,
26+
message: this.message,
27+
};
28+
}
29+
}

src/server/ProxiedApp.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ export class ProxiedApp implements IApp {
6464

6565
public async call(method: AppMethod, ...args: Array<any>): Promise<any> {
6666
if (typeof (this.app as any)[method] !== 'function') {
67-
throw new Error(`The App ${this.app.getName()} (${this.app.getID()}`
68-
+ ` does not have the method: "${method}"`);
67+
throw new Error(`The App ${this.app.getName()} (${this.app.getID()}` + ` does not have the method: "${method}"`);
6968
}
7069

7170
// tslint:disable-next-line
@@ -79,16 +78,14 @@ export class ProxiedApp implements IApp {
7978

8079
let result;
8180
try {
82-
result = await this.runtime.runInSandbox(
83-
`module.exports = app.${method}.apply(app, args)`,
84-
{ app: this.app, args },
85-
);
81+
result = await this.runtime.runInSandbox(`module.exports = app.${method}.apply(app, args)`, { app: this.app, args });
8682
logger.debug(`'${method}' was successfully called! The result is:`, result);
8783
} catch (e) {
8884
logger.error(e);
8985
logger.debug(`'${method}' was unsuccessful.`);
9086

91-
if (e instanceof AppsEngineException) {
87+
const errorInfo = new AppsEngineException(e.message).getErrorInfo();
88+
if (e.name === errorInfo.name) {
9289
throw e;
9390
}
9491
} finally {

0 commit comments

Comments
 (0)