Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for predefined errors. #2

Merged
merged 15 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/BulkQueriesNotSupported.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that bulk queries are not supported on the current subscription plan.
/// </summary>
public static ApiError BulkQueriesNotSupported => new()
{
Code = 604,
Type = "604_bulk_queries_not_supported_on_plan",
Information = "Bulk queries are not supported on the current subscription plan."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/Forbidden.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Access is denied because the current subscription plan does not support the requested API function or HTTPS access.
/// </summary>
public static ApiError Forbidden => new()
{
Code = 403,
Type = "forbidden",
Information = "The user's current subscription plan does not support this API function / HTTPS."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/ForecastDaysNotSupported.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that weather forecast data is not supported on the current subscription plan.
/// </summary>
public static ApiError ForecastDaysNotSupported => new()
{
Code = 609,
Type = "609_forecast_days_not_supported_on_plan",
Information = "Weather forecast data is not supported on the current subscription plan."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/HistoricalQueriesNotSupported.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that historical data is not supported on the current subscription plan.
/// </summary>
public static ApiError HistoricalQueriesNotSupported => new()
{
Code = 603,
Type = "603_historical_queries_not_supported_on_plan",
Information = "Historical data is not supported on the current subscription plan."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/HistoricalTimeFrameTooLong.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified historical time frame exceeds the maximum allowed limit of 60 days.
/// </summary>
public static ApiError HistoricalTimeFrameTooLong => new()
{
Code = 613,
Type = "613_historical_time_frame_too_long",
Information = "The specified historical time frame is too long. (Maximum: 60 days)"
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidForecastDays.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that an invalid value was specified for the number of forecast days.
/// </summary>
public static ApiError InvalidForecastDays => new()
{
Code = 608,
Type = "608_invalid_forecast_days",
Information = "An invalid forecast days value was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidHistoricalDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified historical date is invalid.
/// </summary>
public static ApiError InvalidHistoricalDate => new()
{
Code = 611,
Type = "611_invalid_historical_date",
Information = "An invalid historical date was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidHistoricalTimeFrame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified historical time frame is invalid.
/// </summary>
public static ApiError InvalidHistoricalTimeFrame => new()
{
Code = 612,
Type = "612_invalid_historical_time_frame",
Information = "An invalid historical time frame was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidInterval.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified interval value is invalid
/// </summary>
public static ApiError InvalidInterval => new()
{
Code = 607,
Type = "607_invalid_interval",
Information = "An invalid interval value was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidLanguage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified language code is invalid.
/// </summary>
public static ApiError InvalidLanguage => new()
{
Code = 605,
Type = "605_invalid_language",
Information = "An invalid language code was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/InvalidUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the specified unit value is invalid.
/// </summary>
public static ApiError InvalidUnit => new()
{
Code = 606,
Type = "606_invalid_unit",
Information = "An invalid unit value was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/MissingHistoricalDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that a historical date is missing.
/// </summary>
public static ApiError MissingHistoricalDate => new()
{
Code = 614,
Type = "614_missing_historical_date",
Information = "An invalid historical date was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/MissingQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that a required query value is missing.
/// </summary>
public static ApiError MissingQuery => new()
{
Code = 601,
Type = "601_missing_query",
Information = "An invalid (or missing) query value was specified."
};
}
23 changes: 23 additions & 0 deletions src/Weatherstack/Errors/RequestFailed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 tacosontitan
// This file is part of the Weatherstack project, which is distributed under the MIT license.
// See LICENSE for more information.

/*
The folder containing this file is not intended to be a part of the
namespace, it is purely for organizational purposes.
*/

namespace Weatherstack.Errors;

public static partial class Errors
{
/// <summary>
/// Indicates that the API request has failed.
/// </summary>
public static ApiError RequestFailed => new()
{
Code = 615,
Type = "615_request_failed",
Information = "API request has failed."
};
}
Loading