Skip to content

Commit 4e00c78

Browse files
committed
Handle error types
1 parent 47ce855 commit 4e00c78

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/app/components/urlboard/urlboard.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ export class UrlboardComponent {
1919
.fetchUrls()
2020
.then((d) => (this.state.urls = d.results))
2121
.catch((_) => {
22-
this.state.fetchUrlsError = 'Error fetching your urls';
22+
this.state.fetchUrlsError = true;
2323
});
2424
}
2525

2626
onSubmit() {
2727
this.state.processingRequest = true;
2828
setTimeout(
2929
() => {
30+
this.state.requestError = false;
3031
this.service
3132
.shortenUrl(this.state.form.get('url')?.value)
3233
.then((d) => this.state.urls?.unshift(d))
33-
.catch((e) => console.log(e))
34+
.catch((_) => (this.state.requestError = true))
3435
.finally(() => (this.state.processingRequest = false));
3536
},
3637
environment.production ? 0 : 3000

src/app/states/screen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class MainScreenState {
4242

4343
class URLBoardState {
4444
urls: URL[] | null = null;
45-
fetchUrlsError: string | null = null;
45+
fetchUrlsError: boolean = false;
4646
processingRequest: boolean = false;
47-
requestError: string | null = null;
47+
requestError: boolean = false;
4848
form: FormGroup;
4949

5050
constructor(fb: FormBuilder) {

0 commit comments

Comments
 (0)