This repository was archived by the owner on Sep 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +66
-41
lines changed
Expand file tree Collapse file tree 8 files changed +66
-41
lines changed Original file line number Diff line number Diff line change 22
33module . exports = class CancelledError extends Error {
44 constructor ( ) {
5- super ( ) ;
6-
5+ super ( 'Browser request was cancelled' ) ;
76 this . name = 'CancelledError' ;
8- this . message = 'Browser request was cancelled' ;
9- Error . captureStackTrace ( this , CancelledError ) ;
107 }
118} ;
Original file line number Diff line number Diff line change 11'use strict' ;
2- /**
3- * Special type of error that intended to be reported
4- * to user. Will not print stack trace by default.
5- */
6- function GeminiError ( message , advice ) {
7- Error . captureStackTrace ( this , GeminiError ) ;
8- this . name = 'GeminiError' ;
9- this . message = message ;
10- this . advice = advice ;
11- }
122
13- GeminiError . prototype = Object . create ( Error . prototype ) ;
14- GeminiError . prototype . constructor = GeminiError ;
3+ module . exports = class GeminiError extends Error {
4+ constructor ( message , advice ) {
5+ super ( message ) ;
156
16- module . exports = GeminiError ;
7+ this . name = 'GeminiError' ;
8+ this . advice = advice ;
9+ }
10+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var inherit = require ( 'inherit' ) ,
4- StateError = require ( './state-error' ) ;
3+ const StateError = require ( './state-error' ) ;
54
6- var NoRefImageError = inherit ( StateError , {
7- /**
8- * @constructor
9- * @param {String } refImagePath
10- * @param {StateResult } result
11- */
12- __constructor : function ( refImagePath , currentPath ) {
13- this . name = 'NoRefImageError' ;
14- this . message = 'Can not find reference image at ' + refImagePath + '.\n' +
15- 'Run `gemini update` command to capture all reference images.' ;
5+ module . exports = class NoRefImageError extends StateError {
6+ constructor ( refImagePath , currentPath ) {
7+ super ( `Can not find reference image at ${ refImagePath } .\n` +
8+ 'Run `gemini update` command to capture all reference images.' ) ;
169
10+ this . name = 'NoRefImageError' ;
1711 this . currentPath = currentPath ;
1812 this . refImagePath = refImagePath ;
1913 }
20- } ) ;
21-
22- module . exports = NoRefImageError ;
14+ } ;
Original file line number Diff line number Diff line change 44 * Non-fatal error, occurred during state run.
55 * Fails only single state, not the whole app.
66 */
7- function StateError ( message , originalError ) {
8- Error . captureStackTrace ( this , StateError ) ;
9- this . name = 'StateError' ;
10- this . message = message ;
11- this . originalError = originalError ;
12- }
137
14- StateError . prototype = Object . create ( Error . prototype ) ;
15- StateError . prototype . constructor = StateError ;
8+ module . exports = class StateError extends Error {
9+ constructor ( message , originalError ) {
10+ super ( message ) ;
1611
17- module . exports = StateError ;
12+ this . name = 'StateError' ;
13+ this . originalError = originalError ;
14+ }
15+ } ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const CancelledError = require ( 'lib/errors/cancelled-error' ) ;
4+
5+ describe ( 'CancelledError' , function ( ) {
6+ it ( 'should include the error message in the stacktrace' , function ( ) {
7+ const error = new CancelledError ( ) ;
8+
9+ assert . match ( error . stack , / ^ C a n c e l l e d E r r o r : B r o w s e r r e q u e s t w a s c a n c e l l e d \n / ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const GeminiError = require ( 'lib/errors/gemini-error' ) ;
4+
5+ describe ( 'GeminiError' , function ( ) {
6+ it ( 'should include the given error message in the stacktrace' , function ( ) {
7+ const error = new GeminiError ( 'MyCustomErrorMessage' ) ;
8+
9+ assert . match ( error . stack , / ^ G e m i n i E r r o r : M y C u s t o m E r r o r M e s s a g e \n / ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const NoRefImageError = require ( 'lib/errors/no-ref-image-error' ) ;
4+
5+ describe ( 'NoRefImageError' , function ( ) {
6+ it ( 'should include the error message in the stacktrace' , function ( ) {
7+ const error = new NoRefImageError ( 'anyPath' ) ;
8+
9+ assert . match ( error . stack , / ^ N o R e f I m a g e E r r o r : C a n n o t f i n d r e f e r e n c e i m a g e a t a n y P a t h .\n / ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const StateError = require ( 'lib/errors/state-error' ) ;
4+
5+ describe ( 'StateError' , function ( ) {
6+ it ( 'should include the given error message in the stacktrace' , function ( ) {
7+ const error = new StateError ( 'MyCustomErrorMessage' ) ;
8+
9+ assert . match ( error . stack , / ^ S t a t e E r r o r : M y C u s t o m E r r o r M e s s a g e \n / ) ;
10+ } ) ;
11+ } ) ;
You can’t perform that action at this time.
0 commit comments