1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

handle server errors for attachment save

This commit is contained in:
Kyle Spearrin
2017-11-15 22:36:20 -05:00
parent d9f6607073
commit a166dc65b1
4 changed files with 30 additions and 28 deletions

View File

@@ -9,8 +9,6 @@ class ErrorResponse {
errorModel = response.ErrorModel;
} else if (response) {
errorModel = response;
//} else if (response.responseText && response.responseText.indexOf('{') === 0) {
// errorModel = JSON.parse(response.responseText);
}
if (errorModel) {
@@ -19,6 +17,20 @@ class ErrorResponse {
}
this.statusCode = status;
}
getSingleMessage(): string {
if (this.validationErrors) {
for (const key in this.validationErrors) {
if (!this.validationErrors.hasOwnProperty(key)) {
continue;
}
if (this.validationErrors[key].length) {
return this.validationErrors[key][0];
}
}
}
return this.message;
}
}
export { ErrorResponse };