#16849: Replacing strings and console.writelines by exception throwing.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-12-08 18:18:52 -08:00
parent c57a3ab642
commit 18d1e80189
12 changed files with 78 additions and 84 deletions

View File

@@ -53,12 +53,11 @@ namespace Orchard.Blogs.Commands {
var owner = _membershipService.GetUser(Owner);
if ( owner == null ) {
Context.Output.WriteLine();
return T("Invalid username: {0}", Owner).Text;
throw new OrchardException(T("Invalid username: {0}", Owner));
}
if(!IsSlugValid(Slug)) {
return "Invalid Slug provided. Blog creation failed.";
throw new OrchardException(T("Invalid Slug provided. Blog creation failed."));
}
var blog = _contentManager.New("Blog");
@@ -83,8 +82,7 @@ namespace Orchard.Blogs.Commands {
var owner = _membershipService.GetUser(Owner);
if(owner == null) {
Context.Output.WriteLine();
return T("Invalid username: {0}", Owner).Text;
throw new OrchardException(T("Invalid username: {0}", Owner));
}
XDocument doc;
@@ -95,14 +93,13 @@ namespace Orchard.Blogs.Commands {
Context.Output.WriteLine("Found {0} items", doc.Descendants("item").Count());
}
catch ( Exception ex ) {
Context.Output.WriteLine(T("An error occured while loading the file: " + ex.Message));
return "Import terminated.";
throw new OrchardException(T("An error occured while loading the file: {0}", ex.Message));
}
var blog = _blogService.Get(Slug);
if ( blog == null ) {
return "Blog not found at specified slug: " + Slug;
throw new OrchardException(T("Blog not found at specified slug: {0}", Slug));
}
foreach ( var item in doc.Descendants("item") ) {
@@ -122,7 +119,6 @@ namespace Orchard.Blogs.Commands {
}
}
return "Import feed completed.";
}