mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
rename error util
This commit is contained in:
@@ -3,7 +3,7 @@ import { useError } from "../../(errors)/errorContext";
|
|||||||
import { DomainContext } from "../domainContext";
|
import { DomainContext } from "../domainContext";
|
||||||
import getApi from "../../lib/getApi";
|
import getApi from "../../lib/getApi";
|
||||||
import { useFiefAccessTokenInfo } from "@fief/fief/build/esm/nextjs/react";
|
import { useFiefAccessTokenInfo } from "@fief/fief/build/esm/nextjs/react";
|
||||||
import { shouldShowGet } from "../../lib/errorUtils";
|
import { shouldShowError } from "../../lib/errorUtils";
|
||||||
|
|
||||||
type Mp3Response = {
|
type Mp3Response = {
|
||||||
url: string | null;
|
url: string | null;
|
||||||
@@ -61,7 +61,7 @@ const useMp3 = (protectedPath: boolean, id: string): Mp3Response => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setErrorState(err);
|
setErrorState(err);
|
||||||
const shouldShowHuman = shouldShowGet(error);
|
const shouldShowHuman = shouldShowError(error);
|
||||||
if (shouldShowHuman) {
|
if (shouldShowHuman) {
|
||||||
setError(err, "There was an error loading the audio");
|
setError(err, "There was an error loading the audio");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
import { useError } from "../../(errors)/errorContext";
|
import { useError } from "../../(errors)/errorContext";
|
||||||
import { Topic } from "./webSocketTypes";
|
import { Topic } from "./webSocketTypes";
|
||||||
import getApi from "../../lib/getApi";
|
import getApi from "../../lib/getApi";
|
||||||
import { shouldShowGet } from "../../lib/errorUtils";
|
import { shouldShowError } from "../../lib/errorUtils";
|
||||||
|
|
||||||
type TranscriptTopics = {
|
type TranscriptTopics = {
|
||||||
topics: Topic[] | null;
|
topics: Topic[] | null;
|
||||||
@@ -37,7 +37,7 @@ const useTopics = (protectedPath, id: string): TranscriptTopics => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setErrorState(err);
|
setErrorState(err);
|
||||||
const shouldShowHuman = shouldShowGet(err);
|
const shouldShowHuman = shouldShowError(err);
|
||||||
if (shouldShowHuman) {
|
if (shouldShowHuman) {
|
||||||
setError(err, "There was an error loading the topics");
|
setError(err, "There was an error loading the topics");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { V1TranscriptGetRequest } from "../../api/apis/DefaultApi";
|
|||||||
import { GetTranscript } from "../../api";
|
import { GetTranscript } from "../../api";
|
||||||
import { useError } from "../../(errors)/errorContext";
|
import { useError } from "../../(errors)/errorContext";
|
||||||
import getApi from "../../lib/getApi";
|
import getApi from "../../lib/getApi";
|
||||||
import { shouldShowGet } from "../../lib/errorUtils";
|
import { shouldShowError } from "../../lib/errorUtils";
|
||||||
|
|
||||||
type Transcript = {
|
type Transcript = {
|
||||||
response: GetTranscript | null;
|
response: GetTranscript | null;
|
||||||
@@ -36,7 +36,7 @@ const useTranscript = (
|
|||||||
console.debug("Transcript Loaded:", result);
|
console.debug("Transcript Loaded:", result);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const shouldShowHuman = shouldShowGet(error);
|
const shouldShowHuman = shouldShowError(error);
|
||||||
console.log({ ...error });
|
console.log({ ...error });
|
||||||
if (shouldShowHuman) {
|
if (shouldShowHuman) {
|
||||||
setError(error, "There was an error loading the transcript");
|
setError(error, "There was an error loading the transcript");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
import { AudioWaveform } from "../../api";
|
import { AudioWaveform } from "../../api";
|
||||||
import { useError } from "../../(errors)/errorContext";
|
import { useError } from "../../(errors)/errorContext";
|
||||||
import getApi from "../../lib/getApi";
|
import getApi from "../../lib/getApi";
|
||||||
import { shouldShowGet } from "../../lib/errorUtils";
|
import { shouldShowError } from "../../lib/errorUtils";
|
||||||
|
|
||||||
type AudioWaveFormResponse = {
|
type AudioWaveFormResponse = {
|
||||||
waveform: AudioWaveform | null;
|
waveform: AudioWaveform | null;
|
||||||
@@ -37,7 +37,7 @@ const useWaveform = (protectedPath, id: string): AudioWaveFormResponse => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setErrorState(err);
|
setErrorState(err);
|
||||||
const shouldShowHuman = shouldShowGet(err);
|
const shouldShowHuman = shouldShowError(err);
|
||||||
if (shouldShowHuman) {
|
if (shouldShowHuman) {
|
||||||
setError(err, "There was an error loading the waveform");
|
setError(err, "There was an error loading the waveform");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function shouldShowGet(error: Error | null | undefined) {
|
function shouldShowError(error: Error | null | undefined) {
|
||||||
if (error?.name == "ResponseError" && error["response"].status == 404)
|
if (error?.name == "ResponseError" && error["response"].status == 404)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { shouldShowGet };
|
export { shouldShowError };
|
||||||
|
|||||||
Reference in New Issue
Block a user