本文整理汇总了TypeScript中raven.captureException函数的典型用法代码示例。如果您正苦于以下问题:TypeScript captureException函数的具体用法?TypeScript captureException怎么用?TypeScript captureException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了captureException函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: encodeURIComponent
return error => {
if (enableSentry && shouldReportError(error.originalError)) {
// Generate a clickable link to re-create this error
const baseURL = req.baseUrl
const encodedVars = encodeURIComponent(JSON.stringify(variables))
const encodedQuery = encodeURIComponent(query)
const href = `${baseURL}/graphiql?variables=${encodedVars}&query=${
encodedQuery
}`
raven.captureException(
error,
assign(
{},
{
tags: { graphql: "exec_error" },
extra: {
source: (error.source && error.source.body) || query,
positions: error.positions,
path: error.path,
variables,
href,
},
},
raven.parsers.parseRequest(req)
)
)
} else {
const path =
error.path && error.path.length > 0
? ` (${JSON.stringify(error.path)})`
: ""
log(`${error.message}${path}`)
}
return {
message: error.message,
locations: error.locations,
path: isProduction ? null : error.path,
stack: isProduction ? null : error.stack,
}
}
示例2: next
app.use(async (ctx: Koa.Context, next: () => any) => {
try {
await next();
ctx.set("X-Powered-By", "Clover");
// Handle 404 upstream.
const status = ctx.status || 404;
if (status >= 400) {
ctx.throw(status);
}
} catch (error) {
if (!error.status) {
captureException(error);
log.error(error);
}
ctx.status = error.status || 500;
if (ctx.request.path.startsWith("/api")) {
ctx.body = { message: error.message || "服务器内部错误" };
} else {
ctx.throw(ctx.status);
}
ctx.app.emit("error", error, ctx);
}
});
示例3: Error
const client = Raven.config(dsn, { autoBreadcrumbs: true }).install();
Raven.config(dsn, {
logger: 'logger',
parseUser: ['id', 'name'],
autoBreadcrumbs: false,
});
console.log(Raven.version);
Raven.config(dsn).install({ captureUnhandledRejections: true });
client.setContext({});
client.on('logged', () => { });
client.process({});
client.captureMessage('Broken!', (err, eventId) => { });
new Raven.Client({ name: 'YAY!' });
new Raven.Client(dsn, { name: 'YAY!' });
new Raven.Client(dsn);
try {
throw new Error();
} catch (e) {
const eventId = Raven.captureException(e, (sendErr, eventId) => { });
}
Raven.setContext({});
Raven.mergeContext({});
Raven.context(() => {
Raven.captureBreadcrumb({});
});
setTimeout(Raven.wrap(() => {}), 1000);
Raven.parseDSN('https://8769c40cf49c4cc58b51fa45d8e2d166:296768aa91084e17b5ac02d3ad5bc7e7@app.getsentry.com/269');
示例4:
const handleEPIPE = err => {
Raven.captureException(err)
if (err.code !== 'EPIPE') {
throw err
}
}