Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
f2466a58
Valider
f2466a58
rédigé
11 years ago
par
mattab
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
small refactor of ResponseBuilder to handle 'original' structures
parent
1bfb6bd8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
core/API/ResponseBuilder.php
+44
-32
44 ajouts, 32 suppressions
core/API/ResponseBuilder.php
avec
44 ajouts
et
32 suppressions
core/API/ResponseBuilder.php
+
44
−
32
Voir le fichier @
f2466a58
...
...
@@ -72,6 +72,50 @@ class ResponseBuilder
$this
->
apiModule
=
$apiModule
;
$this
->
apiMethod
=
$apiMethod
;
if
(
$this
->
outputFormat
==
'original'
)
{
@
header
(
'Content-Type: text/plain; charset=utf-8'
);
}
return
$this
->
renderValue
(
$value
);
}
/**
* Returns an error $message in the requested $format
*
* @param Exception $e
* @throws Exception
* @return string
*/
public
function
getResponseException
(
Exception
$e
)
{
$format
=
strtolower
(
$this
->
outputFormat
);
if
(
$format
==
'original'
)
{
throw
$e
;
}
try
{
$renderer
=
Renderer
::
factory
(
$format
);
}
catch
(
Exception
$exceptionRenderer
)
{
return
"Error: "
.
$e
->
getMessage
()
.
" and: "
.
$exceptionRenderer
->
getMessage
();
}
$e
=
$this
->
decorateExceptionWithDebugTrace
(
$e
);
$renderer
->
setException
(
$e
);
if
(
$format
==
'php'
)
{
$renderer
->
setSerialize
(
$this
->
caseRendererPHPSerialize
());
}
return
$renderer
->
renderException
();
}
/**
* @param $value
* @return string
*/
protected
function
renderValue
(
$value
)
{
// when null or void is returned from the api call, we handle it as a successful operation
if
(
!
isset
(
$value
))
{
return
$this
->
handleSuccess
();
...
...
@@ -110,38 +154,6 @@ class ResponseBuilder
return
$this
->
handleScalar
(
$value
);
}
/**
* Returns an error $message in the requested $format
*
* @param Exception $e
* @throws Exception
* @return string
*/
public
function
getResponseException
(
Exception
$e
)
{
$format
=
strtolower
(
$this
->
outputFormat
);
if
(
$format
==
'original'
)
{
throw
$e
;
}
try
{
$renderer
=
Renderer
::
factory
(
$format
);
}
catch
(
Exception
$exceptionRenderer
)
{
return
"Error: "
.
$e
->
getMessage
()
.
" and: "
.
$exceptionRenderer
->
getMessage
();
}
$e
=
$this
->
decorateExceptionWithDebugTrace
(
$e
);
$renderer
->
setException
(
$e
);
if
(
$format
==
'php'
)
{
$renderer
->
setSerialize
(
$this
->
caseRendererPHPSerialize
());
}
return
$renderer
->
renderException
();
}
/**
* @param Exception $e
* @return Exception
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter