lib/monday/util.rb in monday_ruby-0.2.0 vs lib/monday/util.rb in monday_ruby-0.3.0
- old
+ new
@@ -23,9 +23,39 @@
return format_array(value) if value.is_a?(Array)
values
end
+ def status_code_exceptions_mapping(status_code)
+ {
+ "500" => InternalServerError,
+ "429" => RateLimitError,
+ "404" => ResourceNotFoundError,
+ "403" => AuthorizationError,
+ "401" => AuthorizationError,
+ "400" => InvalidRequestError
+ }[status_code.to_s] || Error
+ end
+
+ def response_error_exceptions_mapping(error_code)
+ {
+ "ComplexityException" => [ComplexityError, 429],
+ "UserUnauthorizedException" => [AuthorizationError, 403],
+ "ResourceNotFoundException" => [ResourceNotFoundError, 404],
+ "InvalidUserIdException" => [InvalidRequestError, 400],
+ "InvalidVersionException" => [InvalidRequestError, 400],
+ "InvalidColumnIdException" => [InvalidRequestError, 400],
+ "InvalidItemIdException" => [InvalidRequestError, 400],
+ "InvalidBoardIdException" => [InvalidRequestError, 400],
+ "InvalidArgumentException" => [InvalidRequestError, 400],
+ "CreateBoardException" => [InvalidRequestError, 400],
+ "ItemsLimitationException" => [InvalidRequestError, 400],
+ "ItemNameTooLongException" => [InvalidRequestError, 400],
+ "ColumnValueException" => [InvalidRequestError, 400],
+ "CorrectedValueException" => [InvalidRequestError, 400]
+ }[error_code] || [Error, 400]
+ end
+
private
def format_array(array)
array.map do |item|
item.is_a?(Hash) ? format_hash(item) : item.to_s