var AlertDialog = require('libresignage/ui/components/Dialog/AlertDialog');
var APIError = require('libresignage/api/APIError');

/**
* A class representing an API error alert dialog.
*
* @memberof module:libresignage/ui/components/Dialog
*/
class APIErrorDialog extends AlertDialog {
	/**
	* Construct a new APIErrorDialog object,
	*
	* @param {APIError}            error    The error object to display.
	* @param {BaseDialog_Callback} callback A callback function.
	*/
	constructor(error, callback) {
		let msg = null;

		if (!(error instanceof APIError)) { throw error; }
		super(
			`API HTTP Error ${error.get_status()}`,
			error.get_message() ? error.get_message() : "Unknown error.",
			callback
		);
		console.error(error.toString());
	}
}
module.exports = APIErrorDialog;
