@@ -28,6 +28,7 @@ import {
2828 includeDrive ,
2929 addExternalDrive
3030} from './requests' ;
31+ import { DrivesResponseError } from './handler' ;
3132
3233export class Drive implements Contents . IDrive {
3334 /**
@@ -200,7 +201,7 @@ export class Drive implements Contents.IDrive {
200201 warning = 'Operation not supported.' ;
201202 }
202203 } catch ( err ) {
203- error = 'Download failed: ' + err ;
204+ error = ( err as DrivesResponseError ) . message ;
204205 }
205206
206207 if ( error || warning ) {
@@ -281,7 +282,7 @@ export class Drive implements Contents.IDrive {
281282 type : result . isDir ? 'directory' : result . type !
282283 } ;
283284 } catch ( err ) {
284- error = 'Failed retrieving contents: ' + err ;
285+ error = ( err as DrivesResponseError ) . message ;
285286 }
286287 } else {
287288 // retriving list of contents from root
@@ -305,7 +306,7 @@ export class Drive implements Contents.IDrive {
305306 } ) ;
306307 }
307308 } catch ( err ) {
308- error = 'Failed loading available drives list: ' + err ;
309+ error = ( err as DrivesResponseError ) . message ;
309310 }
310311
311312 data = {
@@ -421,7 +422,7 @@ export class Drive implements Contents.IDrive {
421422 warning = 'Type of new element is undefined' ;
422423 }
423424 } catch ( err ) {
424- error = 'Failed to create object: ' + err ;
425+ error = ( err as DrivesResponseError ) . message ;
425426 }
426427 } else {
427428 // create new element at root would mean creating a new drive
@@ -510,7 +511,7 @@ export class Drive implements Contents.IDrive {
510511 path : formatPath ( localPath )
511512 } ) ;
512513 } catch ( err ) {
513- Notification . emit ( 'Failed deleting object: ' + err , 'error' , {
514+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
514515 autoClose : 5000
515516 } ) ;
516517 }
@@ -607,7 +608,7 @@ export class Drive implements Contents.IDrive {
607608 } ;
608609 }
609610 } catch ( err ) {
610- error = 'Failed renmaing object: ' + err ;
611+ error = ( err as DrivesResponseError ) . message ;
611612 }
612613 } else {
613614 // create new element at root would mean modifying a drive
@@ -718,7 +719,7 @@ export class Drive implements Contents.IDrive {
718719 type : result . type
719720 } ;
720721 } catch ( err ) {
721- error = 'Failed saving object: ' + err ;
722+ error = ( err as DrivesResponseError ) . message ;
722723 }
723724 } else {
724725 // create new element at root would mean modifying a drive
@@ -843,7 +844,7 @@ export class Drive implements Contents.IDrive {
843844 type : result . type !
844845 } ;
845846 } catch ( err ) {
846- error = 'Failed copying object: ' + err ;
847+ error = ( err as DrivesResponseError ) . message ;
847848 }
848849 } else {
849850 // create new element at root would mean modifying a drive
@@ -881,7 +882,7 @@ export class Drive implements Contents.IDrive {
881882 location : region
882883 } ) ;
883884 } catch ( err ) {
884- Notification . emit ( 'Failed creating drive: ' + err , 'error' , {
885+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
885886 autoClose : 5000
886887 } ) ;
887888 }
@@ -919,7 +920,7 @@ export class Drive implements Contents.IDrive {
919920 try {
920921 await addPublicDrive ( driveUrl ) ;
921922 } catch ( err ) {
922- Notification . emit ( 'Failed adding drive: ' + err , 'error' , {
923+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
923924 autoClose : 5000
924925 } ) ;
925926 }
@@ -960,7 +961,7 @@ export class Drive implements Contents.IDrive {
960961 try {
961962 await addExternalDrive ( driveUrl , location ) ;
962963 } catch ( err ) {
963- Notification . emit ( 'Failed adding drive: ' + err , 'error' , {
964+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
964965 autoClose : 5000
965966 } ) ;
966967 }
@@ -998,7 +999,7 @@ export class Drive implements Contents.IDrive {
998999 try {
9991000 await excludeDrive ( driveName ) ;
10001001 } catch ( err ) {
1001- Notification . emit ( 'Failed removing drive: ' + err , 'error' , {
1002+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
10021003 autoClose : 5000
10031004 } ) ;
10041005 }
@@ -1036,7 +1037,7 @@ export class Drive implements Contents.IDrive {
10361037 try {
10371038 await includeDrive ( driveName ) ;
10381039 } catch ( err ) {
1039- Notification . emit ( 'Failed adding drive: ' + err , 'error' , {
1040+ Notification . emit ( ( err as DrivesResponseError ) . message , 'error' , {
10401041 autoClose : 5000
10411042 } ) ;
10421043 }
0 commit comments