Skip to content
Open
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
30 changes: 28 additions & 2 deletions Eventbrite.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
<?php

class EventbriteException extends Exception
{
protected $error_type;

public function __construct($message, $error_type, $code = 0, Exception $previous = null) {
$this->error_type = $error_type;
parent::__construct($message, $code, $previous);
}

public function getType() {
return $this->error_type;
}
}

class EventbriteOauthException extends EventbriteException
{

}

class EventbriteApiException extends EventbriteException
{

}


class Eventbrite {
/**
* Eventbrite API endpoint
Expand Down Expand Up @@ -68,7 +94,7 @@ function oauth_handshake( $tokens ){

$response = get_object_vars(json_decode($json_data));
if( !array_key_exists('access_token', $response) || array_key_exists('error', $response) ){
throw new Exception( $response['error_description'] );
throw new EventbriteOauthException( $response['error_description'], $response['error'] );
}
return array_merge($tokens, $response);
}
Expand Down Expand Up @@ -106,7 +132,7 @@ function __call( $method, $args ) {
$resp = json_decode( $resp );

if( isset( $resp->error ) && isset($resp->error->error_message) ){
throw new Exception( $resp->error->error_message );
throw new EventbriteApiException( $resp->error->error_message, $resp->error->error_type );
}
}
return $resp;
Expand Down