File tree 1 file changed +5
-8
lines changed
Roadmap/10 - EXCEPCIONES/typescript 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ function iniciarApp(){
15
15
iniciarApp ( ) ;
16
16
17
17
//EXTRA
18
- interface errorSuma {
18
+ interface errorObj {
19
19
errorCode :number ,
20
20
body :string
21
21
}
@@ -44,7 +44,7 @@ export class OutOfRange extends CustomError{
44
44
}
45
45
}
46
46
47
- export default function handleError ( error : unknown ) : errorSuma {
47
+ export default function handleError ( error : any ) : errorObj {
48
48
if ( error instanceof CustomError ) {
49
49
return {
50
50
errorCode : error . errorCode ,
@@ -53,7 +53,7 @@ export default function handleError(error: unknown): errorSuma {
53
53
} else {
54
54
return {
55
55
errorCode : 500 ,
56
- body : JSON . stringify ( { error } ) ,
56
+ body : error ,
57
57
} ;
58
58
}
59
59
}
@@ -77,11 +77,8 @@ export default function handleError(error: unknown): errorSuma {
77
77
} catch ( error ) {
78
78
const response = handleError ( error ) ;
79
79
console . warn ( "Código de error: " + response . errorCode )
80
- if ( response . errorCode <= 0 ) {
81
- console . error ( `ERROR: ${ response . errorCode } , ${ response . body } ` ) ;
82
- } else {
83
- console . error ( `ERROR: ${ error } ` ) ;
84
- }
80
+ console . error ( `ERROR: ${ response . errorCode } , ${ response . body } ` ) ;
81
+
85
82
} finally {
86
83
console . log ( "Aplicación finalizada\n" ) ;
87
84
}
You can’t perform that action at this time.
0 commit comments