Skip to content

Commit

Permalink
Merge pull request #586 from MariusVolkhart/mv/improveErrorMessaging
Browse files Browse the repository at this point in the history
Provide additional information during errors
  • Loading branch information
Oren Novotny committed Dec 3, 2018
2 parents 48208e8 + 3b678e4 commit 0960ce0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Refit/RestMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public RestMethodInfo(Type targetInterface, MethodInfo methodInfo, RefitSettings

var ctParams = methodInfo.GetParameters().Where(p => p.ParameterType == typeof(CancellationToken)).ToList();
if(ctParams.Count > 1) {
throw new ArgumentException("Argument list can only contain a single CancellationToken");
throw new ArgumentException($"Argument list to method \"{methodInfo.Name}\" can only contain a single CancellationToken");
}

CancellationToken = ctParams.FirstOrDefault();
Expand All @@ -121,7 +121,7 @@ void VerifyUrlPathIsSane(string relativePath)
return;

bogusPath:
throw new ArgumentException("URL path must be of the form '/foo/bar/baz'");
throw new ArgumentException($"URL path {relativePath} must be of the form '/foo/bar/baz'");
}

Dictionary<int, string> BuildParameterMap(string relativePath, List<ParameterInfo> parameterInfo)
Expand All @@ -141,7 +141,7 @@ Dictionary<int, string> BuildParameterMap(string relativePath, List<ParameterInf
foreach (var match in parameterizedParts) {
var name = match.Groups[1].Value.ToLowerInvariant();
if (!paramValidationDict.ContainsKey(name)) {
throw new ArgumentException(string.Format("URL has parameter {0}, but no method parameter matches", name));
throw new ArgumentException($"URL {relativePath} has parameter {name}, but no method parameter matches");
}

ret.Add(parameterInfo.IndexOf(paramValidationDict[name]), name);
Expand Down Expand Up @@ -294,7 +294,7 @@ void DetermineReturnTypeInfo(MethodInfo methodInfo)
return;

bogusMethod:
throw new ArgumentException("All REST Methods must return either Task<T> or IObservable<T>");
throw new ArgumentException($"Method \"{methodInfo.Name}\" is invalid. All REST Methods must return either Task<T> or IObservable<T>");
}
}
}

0 comments on commit 0960ce0

Please sign in to comment.