feat: show error going to report in console if not in production enviroment

This commit is contained in:
EnixCoda 2019-02-23 20:12:44 +08:00
parent e52d34b74f
commit eed111e2aa
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -32,13 +32,15 @@ function encodeParams<
}
function reportError(error: Error) {
if (!IN_PRODUCTION_MODE) return
return fetch(
`${LOG_ENDPOINT}?${encodeParams({
stack: error.stack,
error: (error && error.message) || error,
path: window.location.href,
version,
})}`,
)
const reportBody = {
stack: error.stack,
error: (error && error.message) || error,
path: window.location.href,
version,
}
if (!IN_PRODUCTION_MODE) {
console.error(reportBody)
return
}
return fetch(`${LOG_ENDPOINT}?${encodeParams(reportBody)}`)
}