Login   Register  
PHP Classes
elePHPant
Icontem

File: exceptions.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Artur Barseghyan  >  PHP TLD Domain Name  >  exceptions.php  >  Download  
File: exceptions.php
Role: Class source
Content type: text/plain
Description: Exceptions
Class: PHP TLD Domain Name
Determine the Top Level Domain from a given URL
Author: By
Last change: License update
Date: 1 year ago
Size: 1,186 bytes
 

Contents

Class file image Download
<?php
/**
 * @package Tld
 * @author Artur Barseghyan (artur.barseghyan@gmail.com)
 * @version 0.1
 * @license MPL 1.1/GPL 2.0/LGPL 2.1
 * @link http://bitbucket.org/barseghyanartur/php-tld
 * 
 * Tld package exceptions.
 */

/**
 * Supposed to be thrown when problems with reading/writing occur.
 */
class TldIOError extends Exception {
    public function 
__construct($message null) {
        if (
null == $message) {
            
$message sprintf("Can't read from or write to the %s file!"Tld::NAMES_LOCAL_PATH);
        }
        
parent::__construct($message);
    }
}

/**
 * Supposed to be thrown when domain name is not found (didn't match) the local TLD policy.
 */
class TldDomainNotFound extends Exception {
    public function 
__construct($domainName) {
        
$message sprintf("Domain %s didn't match any existing TLD name!"$domainName);
        
parent::__construct($message);
    }
}

/**
 * Supposed to be thrown when bad URL is given.
 */
class TldBadUrl extends Exception {
    public function 
__construct($url) {
        
$message sprintf("Is not a valid URL %s!"$url);
        
parent::__construct($message);
    }
}