Added ErrorContainer · Code-Sharp/uHttpSharp@5f0e25a · GitHub
Skip to content

Commit 5f0e25a

Browse files
committed
Added ErrorContainer
1 parent a558771 commit 5f0e25a

4 files changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using uhttpsharp.Handlers;
5+
6+
namespace uhttpsharp.Controllers
7+
{
8+
public class ErrorContainer : IErrorContainer
9+
{
10+
private readonly IList<string> _errors = new List<string>();
11+
12+
public void Log(string description)
13+
{
14+
_errors.Add(description);
15+
}
16+
17+
public IEnumerable<string> Errors
18+
{
19+
get { return _errors; }
20+
}
21+
public bool Any
22+
{
23+
get { return _errors.Count != 0; }
24+
}
25+
public Task<IControllerResponse> GetResponse()
26+
{
27+
return
28+
Task.FromResult<IControllerResponse>(new RenderResponse(HttpResponseCode.MethodNotAllowed,
29+
new {Message = string.Join(", ", _errors)}));
30+
}
31+
}
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using uhttpsharp.Handlers;
4+
5+
namespace uhttpsharp.Controllers
6+
{
7+
public interface IErrorContainer
8+
{
9+
10+
void Log(string description);
11+
12+
IEnumerable<string> Errors { get; }
13+
14+
bool Any { get; }
15+
16+
Task<IControllerResponse> GetResponse();
17+
18+
}
19+
}
Lines changed: 9 additions & 0 deletions

0 commit comments

Comments
 (0)