Skip to content

Commit

Permalink
v1.37.1 (#602)
Browse files Browse the repository at this point in the history
Co-authored-by: Allan RIbeiro <[email protected]>
  • Loading branch information
d-gubert and AllanPazRibeiro authored Mar 21, 2023
1 parent eaa89e4 commit 684bde1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket.chat/apps-engine",
"version": "1.37.0",
"version": "1.37.1",
"description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.",
"main": "index",
"typings": "index",
Expand Down
17 changes: 16 additions & 1 deletion src/definition/exceptions/AppsEngineException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@
* that a user cannot perform some action, e.g.
* join a room
*/
export class AppsEngineException extends Error {}
export class AppsEngineException extends Error {
public name = 'AppsEngineException';
public message: string;

constructor(message?: string) {
super();
this.message = message;
}

public getErrorInfo() {
return {
name: this.name,
message: this.message,
};
}
}
11 changes: 4 additions & 7 deletions src/server/ProxiedApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export class ProxiedApp implements IApp {

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

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

let result;
try {
result = await this.runtime.runInSandbox(
`module.exports = app.${method}.apply(app, args)`,
{ app: this.app, args },
);
result = await this.runtime.runInSandbox(`module.exports = app.${method}.apply(app, args)`, { app: this.app, args });
logger.debug(`'${method}' was successfully called! The result is:`, result);
} catch (e) {
logger.error(e);
logger.debug(`'${method}' was unsuccessful.`);

if (e instanceof AppsEngineException) {
const errorInfo = new AppsEngineException(e.message).getErrorInfo();
if (e.name === errorInfo.name) {
throw e;
}
} finally {
Expand Down

0 comments on commit 684bde1

Please sign in to comment.