-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5161c2
commit 8305fcc
Showing
2 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Platformsh\Cli\CredentialHelper; | ||
|
||
use Platformsh\Cli\Util\OsUtil; | ||
use Symfony\Component\Process\Exception\ProcessFailedException; | ||
use Symfony\Component\Process\Exception\ProcessTimedOutException; | ||
|
||
/** | ||
* An exception thrown when the login keyring is unavailable. | ||
*/ | ||
class KeyringUnavailableException extends \RuntimeException | ||
{ | ||
public static function fromTimeout(ProcessTimedOutException $_) | ||
{ | ||
$type = OsUtil::isOsX() ? 'keychain' : 'keyring'; | ||
$message = sprintf('The credential helper process timed out while trying to access the %s.', $type); | ||
$message .= "\n" . sprintf('This may be due to a system password prompt: is the login %s unlocked?', $type); | ||
return new KeyringUnavailableException($message); | ||
} | ||
|
||
public static function fromFailure(ProcessFailedException $e) | ||
{ | ||
$type = OsUtil::isOsX() ? 'keychain' : 'keyring'; | ||
$message = sprintf('The credential helper process failed while trying to access the %s.', $type); | ||
$process = $e->getProcess(); | ||
if ($process->getExitCode() === 2 && strpos($process->getErrorOutput(), 'libsecret-CRITICAL') !== false) { | ||
$message .= "\n" . sprintf('This can happen when the password dialog is dismissed. Is the login %s unlocked?', $type); | ||
} else { | ||
$message .= "\n" . $e->getMessage(); | ||
} | ||
return new KeyringUnavailableException($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters