Browse Source
Merge pull request #677 from gre/sentry-more-cases
Add a logger.critical for raising exception to Sentry
master
Gaëtan Renaudeau
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
26 additions and
2 deletions
src/components/ThrowBlock.js
src/logger.js
src/renderer/init.js
src/sentry/browser.js
src/sentry/node.js
@ -17,7 +17,7 @@ class ThrowBlock extends PureComponent<Props, State> {
}
componentDidCatch ( error : Error ) {
logger . error ( error )
logger . critical ( error )
this . setState ( { error } )
}
@ -134,15 +134,31 @@ export default {
console . log ( ... args )
addLog ( 'log' , ... args )
} ,
warn : ( ... args : any ) => {
console . warn ( ... args )
addLog ( 'warn' , ... args )
} ,
error : ( ... args : any ) => {
console . error ( ... args )
addLog ( 'error' , ... args )
} ,
critical : ( error : Error ) => {
addLog ( 'critical' , error )
console . error ( error )
try {
if ( typeof window !== 'undefined' ) {
require ( 'sentry/browser' ) . captureException ( error )
} else {
require ( 'sentry/node' ) . captureException ( error )
}
} catch ( e ) {
console . warn ( "Can't send to sentry" , error , e )
}
} ,
exportLogs : ( ) : Array < { type : string , date : Date , args : Array < any > } > =>
logs . map ( ( { type , date , args } ) => ( {
type ,
@ -99,6 +99,6 @@ function r(Comp) {
init ( ) . catch ( e => {
// for now we make the app crash instead of pending forever. later we can render the error OR try to recover, but probably this is unrecoverable cases.
logger . error ( e )
logger . critical ( e )
r ( < AppError error = { e } language = "en" / > )
} )
@ -7,3 +7,7 @@ import install from './install'
export default ( shouldSendCallback : ( ) => boolean ) => {
install ( Raven , shouldSendCallback , user ( ) . id )
}
export const captureException = ( e : Error ) => {
Raven . captureException ( e )
}
@ -6,3 +6,7 @@ import install from './install'
export default ( shouldSendCallback : ( ) => boolean , userId : string ) => {
install ( Raven , shouldSendCallback , userId )
}
export const captureException = ( e : Error ) => {
Raven . captureException ( e )
}