Skip to content

Commit

Permalink
Fix the issue 333 (#336)
Browse files Browse the repository at this point in the history
* Fix bugs w.r.t. test-engine

* Fix for GH issue 333

* Fix for GH issue 333
  • Loading branch information
juileetikekar authored Jul 22, 2024
1 parent e1fbe6c commit 10dda2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace IO.Swagger.Lib.V3.Exceptions
{
public class InvalidPaginationParameterException : Exception
{
public InvalidPaginationParameterException(string paramName, int? value) : base($"Invalid pagination parameter {paramName} value = {value}.")
{

}
}
}
1 change: 1 addition & 0 deletions src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception
message.MessageType = MessageTypeEnum.Error;
break;
}
case InvalidPaginationParameterException:
case Jsonization.Exception:
case InvalidIdShortPathException:
case InvalidUpdateResourceException:
Expand Down
8 changes: 7 additions & 1 deletion src/IO.Swagger.Lib.V3/Models/PaginationParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace IO.Swagger.Models;
namespace IO.Swagger.Models;

using IO.Swagger.Lib.V3.Exceptions;

public class PaginationParameters
{
Expand All @@ -13,6 +15,10 @@ public PaginationParameters(string? cursor, int? limit)
_cursor = string.IsNullOrEmpty(cursor) || !int.TryParse(cursor, out var parsedCursor) ? 0 : parsedCursor;

// Set limit to provided value or default to MaxResultSize
if(limit < 0)
{
throw new InvalidPaginationParameterException("Limit", limit);
}
_limit = limit ?? MaxResultSize;
}

Expand Down

0 comments on commit 10dda2c

Please sign in to comment.