notify library ID conflict (#509)

This commit is contained in:
Cilibiu Bogdan
2018-07-13 22:22:26 +03:00
committed by GitHub
parent 0504b28b3c
commit 53c2e88689
2 changed files with 13 additions and 2 deletions

View File

@@ -112,7 +112,7 @@ export class LibraryDialogComponent implements OnInit {
this.success.emit(folder);
dialog.close(folder);
},
(error) => this.error.emit('LIBRARY.ERRORS.GENERIC')
(error) => this.handleError(error)
);
}
@@ -137,4 +137,14 @@ export class LibraryDialogComponent implements OnInit {
.replace(/[\s]/g, '-')
.replace(/[^A-Za-z0-9-]/g, '');
}
private handleError(error: any): any {
const { error: { statusCode } } = JSON.parse(error.message);
if (statusCode === 409) {
this.form.controls['id'].setErrors({ message: 'LIBRARY.ERRORS.CONFLICT' });
}
return error;
}
}