forked from serverlessworkflow/specification
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Specification): Refactor error handling
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
- Loading branch information
Showing
3 changed files
with
1,066 additions
and
481 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 |
---|---|---|
@@ -1,54 +1,305 @@ | ||
{ | ||
"$id": "https://serverlessworkflow.io/schemas/0.8/errors.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"description": "Serverless Workflow specification - errors schema", | ||
"type": "object", | ||
"errors": { | ||
"oneOf": [ | ||
{ | ||
"type": "string", | ||
"format": "uri", | ||
"description": "URI to a resource containing error definitions (json or yaml)" | ||
}, | ||
{ | ||
"type": "array", | ||
"description": "Workflow Error definitions. Defines checked errors that can be explicitly handled during workflow execution", | ||
"items": { | ||
"type": "object", | ||
"$ref": "#/definitions/errordef" | ||
"$id":"https://serverlessworkflow.io/schemas/0.8/errors.json", | ||
"$schema":"http://json-schema.org/draft-07/schema#", | ||
"description":"Serverless Workflow specification - errors schema", | ||
"type":"object", | ||
"errors":{ | ||
"oneOf":[ | ||
{ | ||
"type":"string", | ||
"format":"uri", | ||
"description":"URI to a resource containing workflow error strategy (json or yaml)" | ||
}, | ||
"additionalItems": false, | ||
"minItems": 1 | ||
} | ||
] | ||
{ | ||
"type":"object", | ||
"description":"The workflow's error handling configuration, including error definitions, error handlers and error policies", | ||
"properties":{ | ||
"definitions":{ | ||
"type":"array", | ||
"description":"Defines errors that can be explicitly handled and/or thrown during workflow execution", | ||
"items":{ | ||
"$ref":"#/definitions/errorDefinition" | ||
}, | ||
"additionalItems":false, | ||
"minItems":1 | ||
}, | ||
"handlers":{ | ||
"type":"array", | ||
"description":"Defines error handlers used to configure what to do when catching specific errors", | ||
"items":{ | ||
"$ref":"#/definitions/errorHandler" | ||
}, | ||
"additionalItems":false, | ||
"minItems":1 | ||
}, | ||
"policies":{ | ||
"type":"array", | ||
"description":"Defines groups of error handlers that define reusable error policies", | ||
"items":{ | ||
"$ref":"#/definitions/errorPolicy" | ||
}, | ||
"additionalItems":false, | ||
"minItems":1 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"required": [ | ||
"errors" | ||
"required":[ | ||
"errors" | ||
], | ||
"definitions": { | ||
"errordef": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "Domain-specific error name", | ||
"minLength": 1, | ||
"pattern": "^[a-z0-9](-?[a-z0-9])*$" | ||
"definitions":{ | ||
"errorDefinition":{ | ||
"type":"object", | ||
"properties":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The name of the error. Must follow the Serverless Workflow Naming Convention.", | ||
"pattern":"^[a-z0-9](-?[a-z0-9])*$" | ||
}, | ||
"source":{ | ||
"type":"string", | ||
"description":"An RFC6901 JSON pointer that precisely identifies the component within a workflow definition (ex: funcRef, subflowRef, ...) from which the described issue originates", | ||
"pattern":"/(\/(([^/~])|(~[01]))*)/g" | ||
}, | ||
"type":{ | ||
"type":"string", | ||
"description":"A RFC3986 URI reference that identifies the problem type. The RFC7807 Problem Details specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML)", | ||
"format":"uri" | ||
}, | ||
"status":{ | ||
"type":"integer", | ||
"description":"The status code generated by the origin for an occurrence of a problem. Status codes are extensible by nature and runtimes are not required to understand the meaning of all defined status codes. However, for cross-compatibility purpose, the specification encourages using RFC7231 HTTP Status Codes" | ||
}, | ||
"title":{ | ||
"type":"string", | ||
"description":"A short, human-readable summary of a problem type. It SHOULD NOT change from occurrence to occurrence of a problem, except for purposes of localization" | ||
}, | ||
"detail":{ | ||
"type":"string", | ||
"description":"A human-readable explanation specific to an occurrence of a problem" | ||
} | ||
}, | ||
"code": { | ||
"type": "string", | ||
"description": "Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'", | ||
"minLength": 1 | ||
"additionalProperties":false, | ||
"required":[ | ||
"name", | ||
"type", | ||
"status", | ||
"source" | ||
] | ||
}, | ||
"errorReference":{ | ||
"oneOf":[ | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"refName":{ | ||
"type":"string" | ||
} | ||
}, | ||
"required":[ | ||
"refName" | ||
], | ||
"additionalProperties":false | ||
}, | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"instance":{ | ||
"type":"string" | ||
}, | ||
"type":{ | ||
"type":"string" | ||
}, | ||
"status":{ | ||
"type":"string" | ||
} | ||
}, | ||
"minProperties":1, | ||
"additionalProperties":false | ||
} | ||
] | ||
}, | ||
"throw":{ | ||
"oneOf":[ | ||
{ | ||
"type":"boolean", | ||
"description":"If true, rethrows the caught error as is" | ||
}, | ||
{ | ||
"type":"object", | ||
"anyOf":[ | ||
{ | ||
"required":[ | ||
"refName" | ||
], | ||
"properties":{ | ||
"refName":{ | ||
"type":"string" | ||
} | ||
} | ||
}, | ||
{ | ||
"required":[ | ||
"type", | ||
"status" | ||
], | ||
"properties":{ | ||
"type":{ | ||
"type":"string" | ||
}, | ||
"status":{ | ||
"anyOf":[ | ||
{ | ||
"type":"integer" | ||
}, | ||
{ | ||
"type":"string" | ||
} | ||
] | ||
}, | ||
"title":{ | ||
"type":"string" | ||
}, | ||
"detail":{ | ||
"type":"string" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"errorHandler":{ | ||
"type":"object", | ||
"properties":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The unique name which is used to reference the handler.", | ||
"pattern":"^[a-z0-9](-?[a-z0-9])*$" | ||
}, | ||
"when":{ | ||
"type":"array", | ||
"items":{ | ||
"$ref":"#/definitions/errorReference" | ||
}, | ||
"description":"References the errors to handle. If null, and if `exceptWhen` is null, all errors are caught.", | ||
"additionalItems":false, | ||
"minItems":1 | ||
}, | ||
"exceptWhen":{ | ||
"type":"array", | ||
"items":{ | ||
"$ref":"#/definitions/errorReference" | ||
}, | ||
"description":"References the errors not to handle. If null, and if `when` is null, all errors are caught.", | ||
"additionalItems":false, | ||
"minItems":1 | ||
}, | ||
"retry":{ | ||
"oneOf":[ | ||
{ | ||
"type":"string", | ||
"description":"The unique name of the retry definition to use" | ||
}, | ||
{ | ||
"$ref":"retries.json#/retries/definitions/retrydef", | ||
"description":"The inline retry definition to use" | ||
} | ||
] | ||
}, | ||
"then":{ | ||
"$ref":"#/definitions/errorOutcomeDefinition" | ||
} | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "Error description" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"name" | ||
] | ||
} | ||
"required":[ | ||
"name" | ||
] | ||
}, | ||
"errorOutcomeDefinition":{ | ||
"type":"object", | ||
"properties":{ | ||
"compensate":{ | ||
"type":"string", | ||
"description":"Unique Name of a workflow state which is responsible for compensation" | ||
}, | ||
"end":{ | ||
"$ref":"workflow.json#/definitions/end" | ||
}, | ||
"transition":{ | ||
"$ref":"workflow.json#/definitions/transition" | ||
}, | ||
"throw":{ | ||
"$ref":"#/definitions/throw" | ||
} | ||
}, | ||
"minProperties":1, | ||
"maxProperties":1 | ||
}, | ||
"errorHandlerReference":{ | ||
"type":"object", | ||
"oneOf":[ | ||
{ | ||
"properties":{ | ||
"refName":{ | ||
"type":"string" | ||
} | ||
}, | ||
"required":[ | ||
"refName" | ||
] | ||
}, | ||
{ | ||
"properties":{ | ||
"when":{ | ||
"type":"array", | ||
"items":{ | ||
"$ref":"#/definitions/errorReference" | ||
} | ||
}, | ||
"exceptWhen":{ | ||
"type":"array", | ||
"items":{ | ||
"$ref":"#/definitions/errorReference" | ||
} | ||
}, | ||
"retry":{ | ||
"oneOf":[ | ||
{ | ||
"type":"string" | ||
}, | ||
{ | ||
"$ref":"#/definitions/retryDefinition" | ||
} | ||
] | ||
}, | ||
"then":{ | ||
"$ref":"#/definitions/errorOutcomeDefinition" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"errorPolicy":{ | ||
"type":"object", | ||
"properties":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The unique name which is used to reference the policy.", | ||
"pattern":"^[a-z0-9](-?[a-z0-9])*$" | ||
}, | ||
"handlers":{ | ||
"type":"array", | ||
"description":"Defines the handlers the policy is made out of", | ||
"items":{ | ||
"$ref":"#/definitions/errorHandlerReference" | ||
}, | ||
"additionalItems":false | ||
} | ||
}, | ||
"required":[ | ||
"name" | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.