File tree Expand file tree Collapse file tree 3 files changed +14
-26
lines changed
Expand file tree Collapse file tree 3 files changed +14
-26
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,9 @@ const _ = require('underscore');
77
88// Class used for all objects passed to error callbacks
99function AVError ( code , message ) {
10- this . code = code ;
11- this . message = message ;
10+ const error = new Error ( message ) ;
11+ error . code = code ;
12+ return error ;
1213}
1314
1415_ . extend ( AVError , {
Original file line number Diff line number Diff line change @@ -47,5 +47,5 @@ const AVError = require('./error');
4747 */
4848AV . Error = ( ...args ) => {
4949 console . warn ( 'AV.Error() is deprecated, and will be removed in next release.' ) ;
50- new AVError ( ...args ) ;
50+ return new AVError ( ...args ) ;
5151} ;
Original file line number Diff line number Diff line change 1- 'use strict' ;
2-
3- var TestError = AV . Object . extend ( "TestError" ) ;
4- describe ( "error" , function ( ) {
5-
6- it ( "return error" , function ( done ) {
7- var test = new TestError ( ) ;
8- test . set ( "num" , 1 ) ;
9- test . save ( ) ;
10- var test1 = new TestError ( ) ;
11- test . set ( "num" , "s" ) ;
12- test . save ( null , {
13- success :function ( obj ) {
14- debug ( obj ) ;
15- done ( ) ;
16- } ,
17- error :function ( obj , err ) {
18- debug ( obj ) ;
19- debug ( err ) ;
20- done ( ) ;
21- }
1+ describe ( 'AVError' , ( ) => {
2+ it ( 'should be an Error' , ( ) => {
3+ try {
4+ throw AV . Error ( - 1 , 'error message' ) ;
5+ } catch ( error ) {
6+ expect ( error ) . to . be . an ( Error ) ;
7+ expect ( error . stack ) . to . be . ok ( ) ;
8+ expect ( error . code ) . to . equal ( - 1 ) ;
9+ expect ( error . message ) . to . equal ( 'error message' ) ;
10+ expect ( error . toString ( ) ) . to . contain ( 'error message' ) ;
2211 }
23- ) ;
2412 } ) ;
25-
2613} ) ;
You can’t perform that action at this time.
0 commit comments