Skip to content

Commit

Permalink
Don't recursively throw new exceptions when the key is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed May 17, 2020
1 parent 0209e5e commit fb6fadc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/InstrumentationKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class InstrumentationKey
/** @var string */
protected $instrumentationKey;

protected static $alreadyThrown = false;

/**
* InstrumentationKey constructor.
Expand Down Expand Up @@ -55,6 +56,12 @@ protected function checkInstrumentationKeyValidity($instrumentationKey)
return true;
}

if (static::$alreadyThrown) {
return false;
}

static::$alreadyThrown = true;

throw new InvalidMSInstrumentationKeyException("'{$instrumentationKey}' is not a valid Microsoft Application Insights instrumentation key.");
}
}

0 comments on commit fb6fadc

Please sign in to comment.