Files
cypress/packages/server/lib/exception.coffee
T
Brian Mann 40813b1954 Issue 416 431 681 980 1248 (#1583)
* extract random string to util

* run specs in isolation, aggregate totalFailures, display output per spec, enable globbing for specs

* extract electron app ready into its own module

* WIP: e2e tests around spec isolation, snapshots, stdout, and complete test results

* removed unused and deprecated remove id's feature

* move fs_warn to fs util to promisify an fs singleton

* create a glob singleton util

* cleanup dead removeIds code

* extract files controller specs into its own file

* extract finding specs out of project instance into its own utility with no state

* use glob util singleton

* use fs util singleton

* lots of formatting and cleanup

* fixes failing headless specs

* fixes all failing unit tests

* fixes failing integration test

* WIP: temporarily throw old error msg

* WIP: skip failing --record integration tests for now

* fix failing e2e tests
2018-04-14 23:13:44 -04:00

55 lines
1.3 KiB
CoffeeScript

_ = require("lodash")
Promise = require("bluebird")
winston = require("winston")
pkg = require("@packages/root")
api = require("./api")
user = require("./user")
Settings = require("./util/settings")
system = require("./util/system")
## strip everything but the file name to remove any sensitive
## data in the path
pathRe = /'?((\/|\\|[a-z]:\\)[^\s']+)+'?/ig
fileNameRe = /[^\s'/]+\.\w+:?\d*$/i
stripPath = (text) ->
(text or "").replace pathRe, (path) ->
fileName = _.last(path.split("/")) or ""
"<stripped-path>#{fileName}"
## POST https://api.cypress.io/exceptions
## sets request body
## err: {}
## version: {}
module.exports = {
getErr: (err) ->
{
name: stripPath(err.name)
message: stripPath(err.message)
stack: stripPath(err.stack)
}
getVersion: ->
pkg.version
getBody: (err) ->
system.info()
.then (systemInfo) =>
_.extend({
err: @getErr(err)
version: @getVersion()
}, systemInfo)
getAuthToken: ->
user.get().then (user) ->
user and user.authToken
create: (err) ->
return Promise.resolve() if process.env["CYPRESS_ENV"] isnt "production"
Promise.join(@getBody(err), @getAuthToken())
.spread (body, authToken) ->
api.createRaygunException(body, authToken)
}