How to use the matrix-js-snippets.LogService.error function in matrix-js-snippets

To help you get started, we’ve selected a few matrix-js-snippets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github turt2live / matrix-dimension / src / api / matrix / MatrixAppServiceApiService.ts View on Github external
public async getRoom(@QueryParam("access_token") homeserverToken: string, @PathParam("alias") roomAlias: string): Promise {
        try {
            const appservice = await AppserviceStore.getByHomeserverToken(homeserverToken);

            // We don't support room lookups
            LogService.verbose("MatrixAppServiceApiService", "404ing request for room " + roomAlias + " at appservice " + appservice.id);
            throw new ApiError(404, {errcode: "IO.T2BOT.DIMENSION.ROOMS_NOT_SUPPORTED"});
        } catch (err) {
            if (err instanceof ApiError) throw err;
            LogService.error("MatrixAppServiceApiService", err);
            throw new ApiError(403, {errcode: "M_FORBIDDEN"});
        }
    }
github turt2live / matrix-dimension / src / api / dimension / DimensionSlackService.ts View on Github external
public async getAuthUrl(@QueryParam("scalar_token") scalarToken: string): Promise<{ authUrl: string }> {
        const userId = await this.accountController.getTokenOwner(scalarToken);

        try {
            const slack = new SlackBridge(userId);
            const authUrl = await slack.getAuthUrl();
            return {authUrl};
        } catch (e) {
            LogService.error("DimensionSlackService", e);
            throw new ApiError(400, "Error getting auth info");
        }
    }
}
github turt2live / matrix-dimension / src / api / dimension / DimensionSlackService.ts View on Github external
public async getChannels(@QueryParam("scalar_token") scalarToken: string, @PathParam("teamId") teamId: string): Promise {
        const userId = await this.accountController.getTokenOwner(scalarToken);

        try {
            const slack = new SlackBridge(userId);
            return slack.getChannels(teamId);
        } catch (e) {
            LogService.error("DimensionSlackService", e);
            throw new ApiError(400, "Error getting channel info");
        }
    }
github turt2live / matrix-dimension / src / api / dimension / DimensionGitterService.ts View on Github external
public async getLink(@QueryParam("scalar_token") scalarToken: string, @PathParam("roomId") roomId: string): Promise {
        const userId = await this.accountController.getTokenOwner(scalarToken);

        try {
            const gitter = new GitterBridge(userId);
            return gitter.getLink(roomId);
        } catch (e) {
            LogService.error("DimensionGitterService", e);
            throw new ApiError(400, "Error getting bridge info");
        }
    }
github turt2live / matrix-dimension / src / api / dimension / DimensionSlackService.ts View on Github external
public async getLink(@QueryParam("scalar_token") scalarToken: string, @PathParam("roomId") roomId: string): Promise {
        const userId = await this.accountController.getTokenOwner(scalarToken);

        try {
            const slack = new SlackBridge(userId);
            return slack.getLink(roomId);
        } catch (e) {
            LogService.error("DimensionSlackService", e);
            throw new ApiError(400, "Error getting bridge info");
        }
    }
github turt2live / matrix-dimension / src / bridges / WebhooksBridge.ts View on Github external
public async getHooks(roomId: string): Promise {
        const bridge = await this.getDefaultBridge();

        try {
            const response = await this.doProvisionRequest(bridge, "GET", `/api/v1/provision/${roomId}/hooks`);
            if (!response.success) throw new Error("Failed to get webhooks");
            return response.results;
        } catch (e) {
            LogService.error("WebhooksBridge", e);
            return [];
        }
    }
github turt2live / matrix-appservice-webhooks / src / WebService.js View on Github external
this._app.use((err, req, res, next) => {
            LogService.error("WebService", err);

            let status = 500;
            let message = "Internal Server Error";
            if (err.message.startsWith("Unexpected token ") && err.message.includes("in JSON at position")) {
                message = err.message;
                status = 400;
            }

            res.status(status);
            res.set('Content-Type', "application/json");
            res.send(JSON.stringify(this._constructError(res, message)));
            next('Error encountered during hook processing');
        });
github turt2live / matrix-dimension / src / matrix / helpers.ts View on Github external
}, (err, res, _body) => {
            if (err) {
                LogService.error("matrix", "Error calling " + endpoint);
                LogService.error("matrix", err);
                reject(err);
            } else if (res.statusCode !== 200) {
                LogService.error("matrix", "Got status code " + res.statusCode + " while calling federated endpoint " + endpoint);
                reject(new Error("Error in request: invalid status code"));
            } else {
                if (typeof (res.body) === "string") res.body = JSON.parse(res.body);
                resolve(res.body);
            }
        });
    });
github turt2live / matrix-appservice-webhooks / src / WebService.js View on Github external
_provisioningApiCatch(error, response) {
        if (error === ProvisioningService.PERMISSION_ERROR_MESSAGE) {
            response.status(400).send({success: false, message: error});
            return;
        }

        LogService.error("WebService", error);
        response.status(500).send({success: false, message: "Unknown error processing request"});
    }
github turt2live / matrix-voyager-bot / src / matrix / matrix_client_lite.ts View on Github external
request(params, (err, response, body) => {
                if (err) {
                    LogService.error("MatrixLiteClient (REQ-" + requestId + ")", err);
                    reject(err);
                } else {
                    if (typeof(body) === 'string') {
                        try {
                            body = JSON.parse(body);
                        } catch (e) {
                        }
                    }

                    LogService.verbose("MatrixLiteClient (REQ-" + requestId + " RESP-H" + response.statusCode + ")", response.body);
                    if (response.statusCode < 200 || response.statusCode >= 300) {
                        LogService.error("MatrixLiteClient (REQ-" + requestId + ")", response.body);
                        reject(response);
                    } else resolve(raw ? response : body);
                }
            });

matrix-js-snippets

A small collection of JS snippets for matrix bots

MIT
Latest version published 6 years ago

Package Health Score

46 / 100
Full package analysis