Skip to content

Commit c194463

Browse files
authored
feat: Actually put error in console, as promised (#131)
1 parent c75f3db commit c194463

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/components/Uploader.tsx

+18-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useUploader
1414
} from '@w3ui/react'
1515
import { gatewayHost } from '../components/services'
16-
import { useState } from 'react'
16+
import { useEffect, useState } from 'react'
1717
import { RadioGroup } from '@headlessui/react'
1818
import { H2 } from './Text'
1919

@@ -62,14 +62,23 @@ export const Uploading = ({
6262
</div>
6363
)
6464

65-
export const Errored = ({ error }: { error: any }): JSX.Element => (
66-
<div className='flex flex-col items-center'>
67-
<h1>
68-
⚠️ Error: failed to upload file: {error.message}
69-
</h1>
70-
<p>Check the browser console for details.</p>
71-
</div>
72-
)
65+
export const Errored = ({ error }: { error: any }): JSX.Element => {
66+
useEffect(() => {
67+
if (error != null) {
68+
// eslint-disable-next-line no-console
69+
console.error('Uploader Error:', error)
70+
}
71+
}, [error])
72+
73+
return (
74+
(<div className='flex flex-col items-center'>
75+
<h1>
76+
⚠️ Error: failed to upload file: {error.message}
77+
</h1>
78+
<p>Check the browser console for details.</p>
79+
</div>)
80+
);
81+
}
7382

7483
interface DoneProps {
7584
file?: File

0 commit comments

Comments
 (0)