Skip to content

Commit 1932a3b

Browse files
#10 - typescript
1 parent 1d589c9 commit 1932a3b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Roadmap/10 - EXCEPCIONES/typescript/RobertoAmaroHub.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function iniciarApp(){
1515
iniciarApp();
1616

1717
//EXTRA
18-
interface errorSuma{
18+
interface errorObj{
1919
errorCode:number,
2020
body:string
2121
}
@@ -44,7 +44,7 @@ export class OutOfRange extends CustomError{
4444
}
4545
}
4646

47-
export default function handleError(error: unknown): errorSuma {
47+
export default function handleError(error: any): errorObj {
4848
if (error instanceof CustomError) {
4949
return {
5050
errorCode: error.errorCode,
@@ -53,7 +53,7 @@ export default function handleError(error: unknown): errorSuma {
5353
} else {
5454
return {
5555
errorCode: 500,
56-
body: JSON.stringify({ error }),
56+
body: error,
5757
};
5858
}
5959
}
@@ -77,11 +77,8 @@ export default function handleError(error: unknown): errorSuma {
7777
} catch(error){
7878
const response = handleError(error);
7979
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+
8582
} finally {
8683
console.log("Aplicación finalizada\n");
8784
}

0 commit comments

Comments
 (0)