本文整理匯總了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
}
}