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

[tcgc] refine error usage #1853

Open
tadelesh opened this issue Nov 13, 2024 · 2 comments
Open

[tcgc] refine error usage #1853

tadelesh opened this issue Nov 13, 2024 · 2 comments
Assignees
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@tadelesh
Copy link
Member

for current tcgc behavior, the error usage will only on models with @error decorator, or models extends model with @error. it does not have any propagation. for this example, ErrorResponse will have usage Error | Output, and ErrorDetail will have usage Output.
the problem here is:

  1. the error does not have propagation which makes it is only a flag, and you could not know error model's reference type
  2. @error is used implicitly as an http exception response in typespec http lib. we have requirement to know if a model is only used in exception response.

after discussed with @ArcturusZhang , we come up with the following proposal:

  1. remove Error usage, add a helper function that indicate if a tcgc type is annotated with @error.
  2. add Exception usage, and for all models used in exception response, they will no longer have Output usage, but have Exception usage.
    with above example, ErrorResponse will have usage Exception, and ErrorDetail will have usage Exception. and call isError for ErrorResponse return true, while for ErrorDetail return false.
@tadelesh tadelesh self-assigned this Nov 13, 2024
@tadelesh tadelesh added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Nov 13, 2024
@haolingdong-msft
Copy link
Member

haolingdong-msft commented Nov 13, 2024

I like the proposal to remove error usage and add exception usage, but just wondering do we need isError helper function to indicate the model has @error decorator? What does downstream use this information for?
And to me, the helper function name isError is a bit confusing. If the helper function indicates whether the model has decoratoror not, the name would better be something like hasErrorDecorator to reduce confusion.

@tadelesh
Copy link
Member Author

tadelesh commented Nov 13, 2024

i think it is just for a replacement for error usage, but i'm fine we do not add it if no languages do need that. i just do not remember clearly how we use error usage for all languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants