Raise Exception

O botão Raise Exception possibilita ao administrador da API editar sua resposta para o cliente em caso de erro dos interceptores ou erros internos.

Se um erro acontecer, o objeto $call.flowError será populado com os seguintes atributos:

  • message: valor que será exibido no corpo da resposta;

  • httpErrorCode: código de erro que será retornado na requisição;

  • position: posição do interceptor em que ocorreu o erro;

  • interceptorType: tipo do interceptor em que houve o erro.

Como usar

O botão está localizado no setor Flows, na área em que são visualizados os interceptores, entre as figuras com os textos Request to Backend e Response to Client:

flow raise exception

Ao clicar no botão Raise Exception, um editor será aberto, conforme a figura abaixo:

flow raise exception editor

No editor, será possível criar scripts para serem executado quando houver uma exceção.

Quando o fluxo conter um script criado pelo Raise Exception, um botão diferente será exibido, significando que o script pode ser editado:

flow editRaiseException

Para remover um script de Raise Exception, basta clicar no X em vermelho ao lado do botão.

Tipos de interceptores e códigos de erros

Tipo Mensagem Erro Requisição Erro Resposta

AccessTokenValidation

This Access Token is expired

403

-

AccessTokenValidation

Access Token is in invalid state (PENDING, REVOKED, CANCELLED, REJECTED)

403

-

AccessTokenValidation

Could not find a required Access Token in the request, identified by (location) (name)

401

-

JsonThreatProtection

Json format invalid

400

500

JsonThreatProtection

Container depth limit exceeds the maximum allowed for this API (10)

400

500

JsonThreatProtection

Object entry count limit exceeds the maximum allowed for this API (10)

400

500

JsonThreatProtection

Object entry name length limit exceeds the maximum allowed for this API (10)

400

500

JsonThreatProtection

Array element count limit exceeds the maximum allowed for this API (30)

400

500

JsonThreatProtection

String value length limit exceeds the maximum allowed for this API (30)

400

500

JsonThreatProtection

JSON threat protection validation failed: Invalid Content-Type in Header → (Content type)

415

415

JsonThreatProtection

JSON threat protection validation failed: Content-Type not found in Header

415

415

XMLThreatProtection

XML format invalid

400

500

XMLThreatProtection

Name limits element exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Name limits attribute exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Name limits namespace prefix exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Name limits processing instruction target exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Structure limits node depth element exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Structure limits attribute count per element exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Structure limits namespace count per element exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Structure limits child count exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Value limits text exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Value limits attribute exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Value limits namespace URI exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Value limits comment exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

Value limits processing instruction data exceeds the maximum allowed for this API (n)

400

500

XMLThreatProtection

XML threat protection validation failed: Invalid Content-Type in Header → (Content type)

415

415

XMLThreatProtection

XML threat protection validation failed: Content-Type not found in Header

415

415

SqlThreatProtection

SQL Injection attack identified in this API Body

400

500

SqlThreatProtection

SQL Injection attack identified in this API Headers

400

500

SqlThreatProtection

SQL Injection attack identified in this API Query Params

400

500

TimeTokenValidation

Could not find a required Time token in the request, identified by (location) (nome)

403

-

TimeTokenValidation

Invalid time token in the request, identified by %s %s

403

-

TokenInterceptor

Error generating token

-

500

TimeAllowed

Time restriction for this API. Works only (hoursOfDay)

429

-

SpikeArrest

urrent Spike Arrest Rate exceeds the maximum Rate of %s call each %s %s for this API

429

-

RestrictAccess

Access denied for this environment.

403

-

RateLimit

Current rate (%s) exceeds the maximum rate (%s) for this API

429

-

PayloadSize

Request size (%s bytes) exceeds the maximum allowed size for this API (%s bytes)

413

-

JWT Validation

JWT %s has an invalid signature

403

-

JWT Validation

JWT is in invalid state %s, rejecting call

403

-

IP Filtering

IP List cannot be null

500

-

IP Filtering

Blocked access from your IP

403

-

Encrypt

An error occurred during the encryption mode

422

-

Encrypt

An error occurred during the encryption mode

422

-

DateTime

The request is out of the accepted date range between: %s and %s"

423

-

Custom Interceptor

Error during process custom interceptor '%s': %s

500

-

ClientID Validation

Could not find a required APP in the request, identified by %s %s

401

-

ClientID Validation

APP is in invalid state %s

403

-

CSRF Validation

Could not find a required CSRF Token in the request, identified by %s, %s

401

-

CSRF Validation

CSRFToken is expired

403

-

CSRF Validation

Requests with different origins

403

-

Exemplo

Verificar Erro de Autorização 401:

 var resp = {};
 if ($call.flowError.httpErrorCode == 401 && $call.flowError.position == 1) {
     resp.msg = "msg error";
 } else {
     resp.msg = "other msg";
 }
 $call.response.getBody().setString($json.stringify(resp), "utf-8");
 $call.response.setHeader("Content-Type", "application/json");

Para informações sobre como escrever um interceptor JavaScript personalizado, clique aqui.

Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]