Open tadelesh opened 1 week ago
I like the proposal to remove error
usage and add exceptionusage
, 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.
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.
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 usageError | Output
, andErrorDetail
will have usageOutput
. the problem here is:@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:
Error
usage, add a helper function that indicate if a tcgc type is annotated with@error
.Exception
usage, and for all models used in exception response, they will no longer haveOutput
usage, but haveException
usage. with above example,ErrorResponse
will have usageException
, andErrorDetail
will have usageException
. and callisError
forErrorResponse
return true, while forErrorDetail
return false.