Class ApodError
Contains information about errors that occured in the request.
Namespace: Apod
Assembly: Apod.dll
Syntax
public class ApodError : object
Remarks
The Apod
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 Apod
Declaration
public ApodError(ApodErrorCode errorCode, string errorMessage = "")
Parameters
Type | Name | Description |
---|---|---|
Apod |
errorCode | The Error |
String | errorMessage | The Error |
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 |
---|---|
Apod |
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 Error
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 Apod
Declaration
public ApodResponse ToApodResponse()
Returns
Type | Description |
---|---|
Apod |
The new Apod |
Remarks
Unless you are overriding internal behaviour, you should not need to call this method.