Class ApodError
Contains information about errors that occured in the request.
Namespace: Apod
Assembly: Apod.dll
Syntax
public class ApodError : object
Remarks
The ApodError aims to give you more information than the API would about what went wrong and what could be done to fix the problem. If you feel like it the information could be more concise in any way, make sure to open a pull request with your proposed changes to the ErrorBuilder and/or the ErrorHandler here: https://github.com/LeMorrow/APOD.Net/compare
Examples
if (response.StatusCode != ApodStatusCode.OK)
{
var error = response.Error;
Console.WriteLine("An error occured.");
Console.WriteLine(error.ErrorCode);
Console.WriteLine(error.ErrorMessage);
}
Example output (where the current date is November 28 2019)
An error occured.
DateOutOfRange
Dates must be between June 16 1995 and November 28 2019.
Constructors
| Improve this Doc View SourceApodError(ApodErrorCode, String)
The default constructor for an ApodError.
Declaration
public ApodError(ApodErrorCode errorCode, string errorMessage = "")
Parameters
Type | Name | Description |
---|---|---|
ApodErrorCode | errorCode | The ErrorCode value. |
String | errorMessage | The ErrorMessage value. |
Remarks
Unless you are overriding internal behaviour, you should not need to call this constructor.
Fields
| Improve this Doc View SourceErrorCode
The error code.
Declaration
public readonly ApodErrorCode ErrorCode
Field Value
Type | Description |
---|---|
ApodErrorCode | The error code. |
Remarks
Useful if you want to make different behaviours depending on the type of error.
If you get the error code Unknown, make sure to open an issue here: https://github.com/LeMorrow/APOD.Net/issues/new?assignees=LeMorrow&labels=bug&template=unknown-error.md&title=Unknown+error
Examples
var error = response.Error;
switch (error.ErrorCode)
{
case ApodErrorCode.DateOutOfRange:
Console.WriteLine(error.ErrorMessage);
break;
case ApodErrorCode.Timeout:
Console.WriteLine("Try with dates that are closer together.");
break;
case ApodErrorCode.OverRateLimit:
Console.WriteLine("You have made too many requests. Come back in a bit.");
break;
default:
Console.WriteLine("An error occured. Try again.");
break;
}
|
Improve this Doc
View Source
ErrorMessage
Information regarding what went wrong and hints for how to resolve it.
Declaration
public readonly string ErrorMessage
Field Value
Type | Description |
---|---|
String | Information regarding what went wrong and hints for how to resolve it. |
Remarks
If you feel like this message could be more concise, make sure to open a pull request with your proposed changes to the ErrorBuilder here: https://github.com/LeMorrow/APOD.Net/compare
Examples
if (response.StatusCode != ApodStatusCode.OK)
{
Console.WriteLine("An error occured.");
Console.WriteLine(response.Error.ErrorMessage);
}
Example output
An error occured.
The count must be positive and cannot exceed 100.
Methods
| Improve this Doc View SourceToApodResponse()
Creates a new ApodResponse with a ApodStatusCode of Error and an ApodError of this instance.
Declaration
public ApodResponse ToApodResponse()
Returns
Type | Description |
---|---|
ApodResponse | The new ApodResponse. |
Remarks
Unless you are overriding internal behaviour, you should not need to call this method.