Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to register a error handlers for services #19117

Closed
ramith opened this issue Sep 19, 2019 · 3 comments
Closed

Ability to register a error handlers for services #19117

ramith opened this issue Sep 19, 2019 · 3 comments
Assignees
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement

Comments

@ramith
Copy link
Contributor

ramith commented Sep 19, 2019

Description:
I propose there has to be a way to register (global and/or per service) error-handlers for ballerina 'service' construct.
Reason: I need to be able to control the behavior (and content) of how errors are transmitted back to client. For example: if I'm running my ballerina service in a local/dev environment I should be able send a descriptive message about the error that occurred while if I'm running in production I probably don't want to reveal too much information to the client.

Now I can do the same thing by checking for each error condition with-in the 'resource'. But reality of that is, amount of 'boiler-plate' code written becomes higher than code written for 'business-logic'.

As per my understanding, programmer can't customize the default behavior.

Affected Versions:
v 1.0.0

OS, DB, other environment details and versions:
Mac, Jdk 1.8

@sameerajayasoma

@sameerajayasoma
Copy link
Contributor

sameerajayasoma commented Sep 20, 2019

@ramith I created the following issue a few days ago. It is related to your requirement.

ballerina-platform/ballerina-spec#337

This issue suggests a workaround to this problem. It is ugly. So you would have to move your service logic to a function and then handle the error at the service.

@sameerajayasoma sameerajayasoma added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement labels Sep 20, 2019
@sameerajayasoma sameerajayasoma self-assigned this Sep 20, 2019
@MaryamZi MaryamZi added this to the Ballerina 1.1.0 milestone Oct 17, 2019
@bruno-garcia
Copy link

Ideally this would be made available to dependencies so services like sentry.io can hook and capture per/request and/or global errors.

@mohanvive
Copy link
Contributor

We can achieve the requirement now using the on-fail clause support in Ballerina. Hence, closing the issue. Please reopen if you need any further clarification on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Projects
None yet
Development

No branches or pull requests

6 participants