Refactoring to use Error instead of string in the useError hook state variable

This commit is contained in:
Koper
2023-09-01 12:36:13 +07:00
parent df4dc841fc
commit 41ca80358c
6 changed files with 23 additions and 61 deletions

View File

@@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
import { DefaultApi, V1TranscriptsCreateRequest } from "../api/apis/DefaultApi";
import { GetTranscript } from "../api";
import { useError } from "../(errors)/errorContext";
import handleError from "../(errors)/handleError";
type UseTranscript = {
response: GetTranscript | null;
@@ -37,10 +36,7 @@ const useTranscript = (api: DefaultApi): UseTranscript => {
console.debug("New transcript created:", result);
})
.catch((err) => {
const errorString = err.response || err.message || "Unknown error";
handleError(setError, errorString, err);
setLoading(false);
console.error("Error creating transcript:", errorString);
setError(err);
});
};