This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a93172
commit 5eec949
Showing
6 changed files
with
110 additions
and
44 deletions.
There are no files selected for viewing
Binary file modified
BIN
+104 Bytes
(100%)
Samples/AlbumViewer/AlbumViewerAngular/Scripts/_references.js
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
Samples/AlbumViewer/AlbumViewerAngular/app/js/errorService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('app') | ||
.service('errorService', errorService); | ||
|
||
errorService.$inject = []; | ||
|
||
function errorService() { | ||
var vm = { | ||
message: null, | ||
icon: "warning", | ||
reset: function() { | ||
vm.message = null; | ||
vm.icon = "warning"; | ||
}, | ||
error: function(message, icon) { | ||
vm.error.reset(); | ||
vm.error.message = message; | ||
if (!icon) | ||
icon = "error"; | ||
|
||
vm.icon = icon; | ||
}, | ||
info: function(message, icon) { | ||
vm.reset(); | ||
vm.message = message; | ||
if (!icon) | ||
icon = "info"; | ||
vm.icon = icon; | ||
}, | ||
parseHttpError: function() { | ||
var args = arguments; | ||
|
||
// error/message object passed rather than parm object | ||
if (args.hasOwnProperty("message")) { | ||
vm.message = args.message; | ||
return; | ||
} | ||
if (args.hasOwnProperty("Message")) { | ||
vm.message = args.Message; | ||
return; | ||
} | ||
|
||
var data = args[0]; // http content | ||
var status = args[1]; | ||
var msg = args[2]; | ||
if(typeof msg != "String") | ||
msg = null; | ||
|
||
if (data) { | ||
if (data.hasOwnProperty("message")) { | ||
vm.message = data.message; | ||
return; | ||
} | ||
if (data.hasOwnProperty("Message")) { | ||
vm.message = data.Message; | ||
return; | ||
} | ||
|
||
// assume JSON | ||
try { | ||
var msg = JSON.parse(data); | ||
if (msg && msg.hasOwnProperty("message")) | ||
vm.message = msg.message; | ||
else if (msg.hasOwnProperty("Message")) | ||
vm.message = msg.Message; | ||
|
||
if(vm.message) | ||
return; | ||
} catch (exception) {} | ||
} | ||
if (!msg) { | ||
if (status === 404) | ||
msg = "URL not found."; | ||
else if (status === 401) | ||
msg = "Not authorized."; | ||
else | ||
msg = "Unknown error. Status: " + status; | ||
} | ||
vm.message = msg; | ||
} | ||
}; | ||
|
||
this.error = vm; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters