raisely / cli

Raisely CLI for local development
Other
8 stars 6 forks source link

Improve invalid CSS/SCSS error handling #6

Closed f1yn closed 2 years ago

f1yn commented 4 years ago

Right now, any invalid Sass in styles will dump something like this to stderr:

Saving {campaignName}/_core/global.scss(node:54061) UnhandledPromiseRejectionWarning: StatusCodeError: 400 - {"status":400,"time":"2020-04-18T01:17:30.510Z","errors":[{"code":"invalid syntax","status":400,"message":"Sass error: \"Invalid CSS after \"}\": expected 1 selector or at-rule, was \".profilelist. .pagi\"\"","detail":"One or more of the values you sent was not of the correct syntax. Please check the format of the values you are sending.","title":"Invalid Syntax"}]}
    at new StatusCodeError (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request/request.js:185:22)
    at Request.emit (events.js:210:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at Request.<anonymous> (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:210:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at IncomingMessage.<anonymous> (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely/cli/node_modules/request/request.js:1076:12)
(node:54061) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:54061) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
⠇ Saving {campaignName}/_core/global.scss(node:54061) UnhandledPromiseRejectionWarning: StatusCodeError: 400 - {"status":400,"time":"2020-04-18T01:17:55.817Z","errors":[{"code":"invalid syntax","status":400,"message":"Sass error: \"Invalid CSS after \"}\": expected 1 selector or at-rule, was \".profilelist. .pagi\"\"","detail":"One or more of the values you sent was not of the correct syntax. Please check the format of the values you are sending.","title":"Invalid Syntax"}]}
    at new StatusCodeError (/Users/flynn/.nvm/versions/node/v12.13.1/lib/node_modules/@raisely

This should be cleaned up to only show the Sass error for this specific function. Otherwise, all stderr traces should be hidden behind a debug or verbose flag.