Origin/fix file response exception handling#30
Origin/fix file response exception handling#30galym-abitech wants to merge 6 commits intoDotNetNomads:masterfrom
Conversation
…/github.com/galym-abitech/NextApi into origin/fix_file_response_exception_handling
…ttps://github.com/galym-abitech/NextApi into origin/fix_file_response_exception_handling" This reverts commit 65197c9, reversing changes made to 4d57060.
|
|
||
| private async Task<T> InvokeHttpMessagePack<T>(HttpResponseMessage response) | ||
| { | ||
| var mediaType = response.Content.Headers.ContentType.MediaType; |
There was a problem hiding this comment.
There is already block with same definitions on lines 305-317. Both InvokeHttpJson and the InvokeHttpMessagePack are being used in InvokeHttp. Perhaps, put this block in a separate method, for example in NextApiUtils, or put it in a calling method InvokeHttp, to not repeat same code over again.
| } | ||
| default: | ||
| throw new Exception($"Unsupported serialization type {HttpSerializationType}"); | ||
| catch { } |
There was a problem hiding this comment.
Should throw an exception with type NextApiException, like it been made in line 315.
| await connection.StartAsync(); | ||
| }; | ||
| connection.On("NextApiEvent", new[] {typeof(NextApiEventMessage)}, ProcessNextApiEvent); | ||
| connection.On("NextApiEvent", new[] { typeof(NextApiEventMessage) }, ProcessNextApiEvent); |
There was a problem hiding this comment.
Not really critical, but it is better to leave it be, or add these whitespaces everywhere to have same code-style. And yet, to get rid of this unnecessary change.
| var result = (NextApiResponse)MessagePackSerializer.Typeless.Deserialize(resultByteArray); | ||
|
|
||
| if (!result.Success) | ||
| { |
There was a problem hiding this comment.
That is not really critical too, but it is better to get rid of these curly braces to have same code-style everywhere, 'cause NextApi's code style assumes, that single-line conditions will not have them.
| string GetCurrentUser(); | ||
| Task<string> UploadFile(Stream fileStream, string fileName); | ||
| Task<NextApiFileResponse> GetFile(string path); | ||
| Task<NextApiFileResponse> GetFile(string path, bool throwException = false); |
There was a problem hiding this comment.
I think, that it is better to add another mock method, instead of modifying existing one, that will have return type of Task<NextApiFileResponse>, will accept only path, and will always throw an exception, if you really need it.
For example: Task<NextApiFileResponse> GetFileException(string path);
Add File Response exception handling in next api client for properly display error message