mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#16849: Replacing strings and console.writelines by exception throwing.
--HG-- branch : dev
This commit is contained in:
@@ -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.";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user