You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
the error does not have propagation which makes it is only a flag, and you could not know error model's reference type
@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:
remove Error usage, add a helper function that indicate if a tcgc type is annotated with @error.
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.
The text was updated successfully, but these errors were encountered:
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.
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.The text was updated successfully, but these errors were encountered: