-
Notifications
You must be signed in to change notification settings - Fork 19
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
Generate error codes #171
Generate error codes #171
Conversation
ok, so now we have two scripts that process the It is the responsibility of the library to make sure it's not broken if the ably-common submodule ref is updated. If that requires a static check then yes, something ought to be done to ensure that. |
Sorry, I don't follow. Where is the second script? Code generators will surely always be different for every language? |
@gernest wrote one, which can output for any language based on a template, and my ably-common issue was (in part) the proposal to include that in that repo. |
@paddybyers I think @mattheworiordan approach is okay. It feels more natural that having a go binary doing that. Each language can use the language's tools to generate the constants. And just to clear things, my script is only generating go code for now, I only pointed out that it uses templates so it is possible to do that for other languages see ably/ably-go#72. |
@gernest right, but I wanted to make sure that at least we use consistent logic for converting the error strings into constant names so a single approach, if generic enough, would be best. |
But every language has an idiomatic way of defining constants, so why would we try to centralise this in one place, and also make it impossible for other devs to maintain their libs without getting Go code / templates written? |
@mattheworiordan: I think what @gernest is getting at is that it wouldn't require writing Go at all, just templates with a fairly self-explanatory syntax if you see an example. Right now the template in ably/ably-go#72 is baked in, but reading it from a file is trivial. So one centralised tool (which doesn't have to reside in the Go lib repo) for generating the error code constants for any language there's a template for. Customers don't need to be exposed to it if we keep an up-to-date version of the constants in |
Well perhaps, I don't think it makes much difference to be honest. I would say that it's a lot easier this way around in that no one has to do PRs on other repos just to get their constants in, but I don't feel that strongly about it. A data type (JSON) IMHO is far more predictable as a dependency than a templating language in another repo. |
3ae5302
to
25e3989
Compare
@paddybyers @SimonWoolf see acae470. If you are happy with this, I think I would like to raise issues in all libs to follow suit. |
Well sure, I agree that makes sense if the only time an error generated is from realtime. Client libraries generate errors too. See
Sure, but an error code should still map to an error URL no? |
Yes, that's why my suggestion was to use the absence of
The href field in an error realtime returns can contain whatever we like. Probably almost all of the time it will just contain But maybe sometimes it won't. E.g. maybe we'll have a code that covers multiple different cases that we can't change for backwards-compatibility reasons, but we could still link to different appropriate solutions article for each case. We have that flexibility; it seems silly to throw it away by imposing an unnecessary constraint on future-us that all urls have to be |
Ok, so pre 1.2, add href to the message if
Yes. Although it's
Why not? Letting client lib SDKs decide when it's appropriate or not is dangerous. I don't really follow what the downside is. We have systems in place to detect error codes that are being viewed and we don't have articles for, and we have a support system that can grow as our needs evolve. If you need to additionally include an
Options are:
We're not throwing away any flexibility. We're introducing a uniform way to approach error codes that improves developer experience. Leaving this to the discretion of the developer is throwing away the opportunity to uniformly improve things. It also encourages everyone to think carefully about the error codes they use so that we build a meaningful knowledgebase of error codes and what they mean. The absence of this is what encourages people to write error messages that customers don't understand, and get in touch with us if we're lucky, or worse just leave. |
I'm a bit confused right now -- I've no idea what thing you think I was saying that we should let client libs decide. Lets chat it over at the standup this week? |
Typo, I meant client lib SDK developers decide. I see, so you are saying that realtime (not the client libraries) reserves the right to send any href it likes right? And any client lib generated error, which has an error code too, would default to |
Yes. Currently realtime only sends errors with a canonical |
One thing to bear in mind, is that people search for error codes. Sure, they can follow a link from an error message, but they may just search too, such as https://www.ably.io/support?addsearch=40101. Of course we could override the default generated help URL from realtime, or from the client lib, but we still need to remember that the error code may lead that person to a support article on that error code. |
@paddybyers @SimonWoolf how about ea425be? Does that solve the problems of not duplicating error URLs unnecessarily, and providing flexibility to realtime or the client libs to specify their own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@paddybyers you happy with that? If so, I am going to raise an issue in all libraries to follow suit ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
See ably/ably-common#32
Whilst I do like this, I am concerned that a change to the wording in the
errors.json
file (which is reasonable to do), could now result in this library being very broken i.e. an exception that causes the library to exit.I have added
3f8351b
which may help.One other approach is to keep a list of used constants at the top of each file so that it will break immediately when the library is loaded, but that feels a bit heavy handed. Perhaps we should do this though in untyped languages to ensure the libraries don't become brittle and fail badly at the wrong time. WDYT?