Commit 4fbe4467616177809ecbbb15eee0ea103f440662

Authored by Lucas Schmoeller da Silva
1 parent c8aac5f1
Exists in 2.8 and in 6 other branches 2.2, 2.3, 2.4, 2.5, 2.6, 2.7

Add mensagens de erros conhecidas para o i-Diário

Refs portabilis/novo-educacao#2749
ieducar/modules/Api/Views/DiarioController.php
... ... @@ -73,7 +73,13 @@ class DiarioController extends ApiCoreController
73 73  
74 74 $valid = in_array($componenteCurricularId, $componentesTurma);
75 75 if (!$valid) {
76   - throw new CoreExt_Exception("Componente curricular de código $componenteCurricularId não existe para a turma $turmaId .");
  76 + $this->messenger->append("Componente curricular de código {$componenteCurricularId} não existe para a turma {$turmaId}.", 'error');
  77 + $this->appendResponse('error', [
  78 + 'code' => Error::DISCIPLINE_NOT_EXISTS_FOR_SCHOOL_CLASS,
  79 + 'message' => "Componente curricular de código {$componenteCurricularId} não existe para a turma {$turmaId}.",
  80 + ]);
  81 +
  82 + return false;
77 83 }
78 84  
79 85 return $valid;
... ... @@ -402,7 +408,13 @@ class DiarioController extends ApiCoreController
402 408 }
403 409  
404 410 if ($this->getRegra($matriculaId)->get('tipoPresenca') != RegraAvaliacao_Model_TipoPresenca::POR_COMPONENTE) {
405   - throw new CoreExt_Exception(Portabilis_String_Utils::toLatin1("A regra da turma $turmaId não permite lançamento de faltas por componente."));
  411 + $this->messenger->append("A regra da turma $turmaId não permite lançamento de faltas por componente.", 'error');
  412 + $this->appendResponse('error', [
  413 + 'code' => Error::SCHOOL_CLASS_DOESNT_ALOW_FREQUENCY_BY_DISCIPLINE,
  414 + 'message' => "A regra da turma $turmaId não permite lançamento de faltas por componente.",
  415 + ]);
  416 +
  417 + return false;
406 418 }
407 419  
408 420 foreach ($faltaTurmaAluno as $componenteCurricularId => $faltaTurmaAlunoDisciplina) {
... ...
src/Support/Exceptions/Error.php
... ... @@ -14,4 +14,6 @@ class Error
14 14 const EVALUATION_RULE_NOT_DEFINED_IN_LEVEL = 1007;
15 15 const EVALUATION_RULE_NOT_ALLOW_GENERAL_ABSENCE = 1008;
16 16 const DISCIPLINE_NOT_ENROLLED_IN_SCHOOL_LEVELS = 1009;
  17 + const DISCIPLINE_NOT_EXISTS_FOR_SCHOOL_CLASS = 1010;
  18 + const SCHOOL_CLASS_DOESNT_ALOW_FREQUENCY_BY_DISCIPLINE = 1011;
17 19 }
18 20 \ No newline at end of file
... ...