- Sep 2023
-
mywiki.wooledge.org mywiki.wooledge.org
-
stackoverflow.com stackoverflow.com
-
commands="\nthing1@this is thing 1\!\nthing2@this is thing 2!" while read line;do // do your stuff here line <<< $( echo -e "${commands}" )
Seems to work. Not used to the <<< expression...
-
-
unix.stackexchange.com unix.stackexchange.com
-
Using quotes for i in "$(cat $1)"; results in i being assigned the whole file at once. What should I change?
-
-
stackoverflow.com stackoverflow.com
-
Bash doesn't do word expansion on quoted strings in this context. For example: $ for i in "a b c d"; do echo $i; done a b c d $ for i in a b c d; do echo $i; done a b c d
-
- Aug 2023
-
stackoverflow.com stackoverflow.com
-
The question is also not about error handling and if the file write fails, exiting with a stack trace is reasonable default behavior because there's not much you can do to recover from that.
-
-
stackoverflow.com stackoverflow.com
-
Active job instances include ActiveSupport::Rescuable which means you can use rescue_from in a job in the same way you can in a controller.
-
- Jul 2023
-
wesmckinney.com wesmckinney.com
-
You might want to suppress only ValueError, since a TypeError (the input was not a string or numeric value) might indicate a legitimate bug in your program. To do that, write the exception type after except: def attempt_float(x): try: return float(x) except ValueError: return x
-
- Nov 2022
-
github.com github.com
-
The first being signal handling. If the process launched does not handle SIGTERM by exiting, it will not be killed since it is PID 1 in the container
-
-
-
Tini does install explicit signal handlers (to forward them, incidentally), so those signals no longer get dropped. Instead, they're sent to Jenkins, which is not running as PID 1 (Tini is), and therefore has default signal handlers
-
-
github.com github.com
-
I just spent a day dismantling a model, trying to find the cause of the silent rollback - taking out every association, every validation, every callback, whittling down all the code in the transaction, only to finally discover that it was return true that was the cause of it all. Or yes, an exception!
-
- Sep 2022
-
metalblueberry.github.io metalblueberry.github.io
-
This code is much easier to understand as it do not add levels of indentation and follows the principle where the 0 indentation level is the principal path of the application where other paths are exceptions or rare cases.
-
-
www.postgresql.org www.postgresql.org
-
Otherwise behaves according to the value of null_value_treatment which must be one of 'raise_exception', 'use_json_null', 'delete_key', or 'return_target'. The default is 'use_json_null'.
-
- Jul 2022
-
via3.hypothes.is via3.hypothes.is
-
1. Focus on items that occur with high frequency in the language as awhole (see Table 3.1 for examples). Such items will occur often inmany different texts.2. Focus on strategies that can be used with most texts (see Table 3.1for examples).
.c1
-
- Jan 2022
-
javascript.info javascript.info
-
new Promise(function(resolve, reject) { setTimeout(() => { throw new Error("Whoops!"); }, 1000); }).catch(alert);
-
-
github.com github.com
-
The best you can do is try/catch inside a function that is reactively called, but my goal is to have a global exception handler to handle all exceptions that I did not expect...
-
-
-
If at least one component has smallest unhandled error, the whole app will crash and users will not know what to do and developers will not know such an error occurred.
-
Boilerplate is only boilerplate if it's the same everywhere, which it shouldn't be.
-
-
-
thecodebarbarian.com thecodebarbarian.com
-
Some argue that throwing an exception in the executor function is bad practice. I strongly disagree.
-
- Jul 2021
-
stackoverflow.com stackoverflow.com
-
Throw it's a more elegant way to use an exception-like system as a control flow.
-
- Jun 2021
-
mywiki.wooledge.org mywiki.wooledge.org
-
Bash (like all Bourne shells) has a special syntax for referring to the list of positional parameters one at a time, and $* isn't it. Neither is $@. Both of those expand to the list of words in your script's parameters, not to each parameter as a separate word.
-
-
superuser.com superuser.com
-
Instead of using a for loop, which will fail on spaces unless you redefine the IFS variable, I would recommend using a while loop combined with find.
-
-
disqus.com disqus.com
-
Handling 401s well is important for the user's experience. They won't happen often (though more often than I expected), but really do break everything if you're not careful. Getting a good authentication abstraction library for Vue or Ember or whatever you are using should help with a lot of the boring parts. You'll probably need to define some extra strategies/rules for this cookie session approach, but if it's anything like in ember-simple-auth they're so simple it feels like cheating, because the Rails app is doing all of the hard work and you just need the js part to spot a 401 and handle logging in and retrying whatever it was doing before.
Tags
Annotators
URL
-
- May 2021
-
www.bbc.co.uk www.bbc.co.uk
-
Covid: India tells social media firms to remove ‘India variant’ from content. (2021, May 22). BBC News. https://www.bbc.com/news/world-asia-india-57213046
-
- Apr 2021
-
www.geeksforgeeks.org www.geeksforgeeks.org
-
Drop missing values from the dataframeIn this method we can see that by using dropmissing() method, we are able to remove the rows having missing values in the data frame. Drop missing values is good for those datasets which are large enough to miss some data that will not affect the prediction and it’s not good for small datasets it may lead to underfitting the models.
Listwise Deletion
-
-
en.wikipedia.org en.wikipedia.org
-
The basic rule of thumb is: "I'm not aware of all types of security exploits. I must protect against those I do know of and then I must be proactive!".
-
- Mar 2021
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
A one-liner alternative for hash-only cases can be implemented using Enumerable#reduce: root = {} [:a, :b, :c].reduce(root){@1[@2]||={}}[:d] = 'E' # root => {:a=>{:b=>{:c=>{:d=>"E"}}}}
-
I think the issues/problems specified in the comments are not present with a Hash-only implementation. :) I would be supportive of re-considering this feature just for use with a Hash, where I believe 80% of the real-life use cases would (and do) exist. I have encountered this need before in the wild, but not with Arrays.
-
-
github.com github.compry/pry1
-
you can use the wtf? command to display a few lines of the backtrace for the most recent exception
-
- Feb 2021
-
trailblazer.to trailblazer.to
-
the ability to “error out” when something goes wrong
-
If anything here did fail in “validate omniauth”, all other steps in the chain would be skipped as the flow would follow the path leading to the failure terminus.
-
Things could go wrong in two places here. First, the validation could fail if Github sends us data we don’t understand. Second, we might not know the user signing in, meaning the “find user” logic has to error-out
-
-
sobolevn.me sobolevn.me
-
Literally, everything in this example can go wrong. Here’s an incomplete list of all possible errors that might occur: Your network might be down, so request won’t happen at all The server might be down The server might be too busy and you will face a timeout The server might require an authentication API endpoint might not exist The user might not exist You might not have enough permissions to view it The server might fail with an internal error while processing your request The server might return an invalid or corrupted response The server might return invalid json, so the parsing will fail And the list goes on and on! There are so maybe potential problems with these three lines of code, that it is easier to say that it only accidentally works. And normally it fails with the exception.
-
Return None. That’s evil too! You either will end up with if something is not None: on almost every line and global pollution of your logic by type-checking conditionals, or will suffer from TypeError every day. Not a pleasant choice.
-
we also wrap them in Failure to solve the second problem: spotting potential exceptions is hard
-
Exceptions are just like notorious goto statements that torn the fabric of our programs.
-
So, the sad conclusion is: all problems must be resolved individually depending on a specific usage context. There’s no silver bullet to resolve all ZeroDivisionErrors once and for all. And again, I am not even covering complex IO flows with retry policies and expotential timeouts.
Tags
- accidentally works
- depends on use case / application
- the specific context is important
- exceptions that are not exceptional
- anticipating what could go wrong / error/exception cases
- error/exception handling
- error/exception handling: spotting potential exceptions is hard
- exceptions are expectable, not exceptional
- easy to miss / not notice (attention)
- programming: goto
- need to solve specific case/problems individually (there is no general solution)
- analogy
- sad/unfortunate conclusion
- traditional exception handling (try/catch; begin/rescue)
- can't think of everything
- too many ifs: bad
- difficult/hard problem
Annotators
URL
-
-
-
certainly I wouldn't want it to start telling me that I'm not catching these!
-
-
www.morozov.is www.morozov.is
-
Railway Oriented Programming is a way to gracefully handle errors in your application
-
-
dry-rb.org dry-rb.org
-
Monads provide an elegant way of handling errors, exceptions and chaining functions so that the code is much more understandable and has all the error handling, without all the ifs and elses.
-
-
jrsinclair.com jrsinclair.com
-
-
As you can see, we end up with a lot of boilerplate if-statements. The code is more verbose. And it’s difficult to follow the main logic.
-
In JavaScript, we have a built-in language feature for dealing with exceptions. We wrap problematic code in a try…catch statement. This lets us write the ‘happy path’ in the try section, and then deal with any exceptions in the catch section. And this is not a bad thing. It allows us to focus on the task at hand, without having to think about every possible error that might occur.
-
And they are not the only way to handle errors.
-
In this article, we’ll take a look at using the ‘Either monad’ as an alternative to try...catch.
Tags
- JavaScript
- verbose / noisy / too much boilerplate
- monad: Either
- error/exception handling
- happy path
- replacement for:
- elegant solution
- hard to follow/read/understand
- traditional exception handling (try/catch; begin/rescue)
- excellent technical writing
- different way of solving/implementing something
- sad path
Annotators
URL
-
-
functionalprogramming.medium.com functionalprogramming.medium.com
-
en.wikipedia.org en.wikipedia.org
-
Maybe T can be understood as a "wrapping" type, wrapping the type T into a new type with built-in exception handling
-
Undefined values or operations are one particular problem that robust software should prepare for and handle gracefully.
-
-
blog.logrocket.com blog.logrocket.com
-
This style of error handling uses monadic behavior — a substitute way of handling errors.
-
-
unix.stackexchange.com unix.stackexchange.com
-
stackoverflow.com stackoverflow.com
-
Both kill with a job specifier and terminal signals send to the entire process group, so both the shell and sleep.
-
-
stackoverflow.com stackoverflow.com
-
I am trying to understand how CTRL+C terminates a child but not a parent process. I see this behavior in some script shells like bash where you can start some long-running process and then terminate it by entering CTRL-C and the control returns to the shell. Could you explain how does it work and in particular why isn't the parent (shell) process terminated? Does the shell have to do some special handling of CTRL+C event and if yes what exactly does it do?
-
-
unix.stackexchange.com unix.stackexchange.com
-
stackoverflow.com stackoverflow.com
-
Remove your last "just in case" trap, and the script should work fine also with the EXIT traps. INT in the trap calling the cleanup should be the correct way to deal with the interrupts, however
-
-
stackoverflow.com stackoverflow.com
-
Personally, I prefer signalling an error for invalid values
-
-
-
You can rescue at the method level, but more likely you’d want to rescue at the statement level.
-
-
github.com github.com
-
Other filters will ignore blocks when given to them.
Would be better to raise an error if block isn't allowed/expected!
-
Note that it's perfectly fine to add errors during execution. Not all errors have to come from type checking or validation.
-
Inside the interaction, we could use #find instead of #find_by_id. That way we wouldn't need the #find_account! helper method in the controller because the error would bubble all the way up. However, you should try to avoid raising errors from interactions. If you do, you'll have to deal with raised exceptions as well as the validity of the outcome.
What they're referring to:
Account.find('invalid')
will raise an error butAccount.find_by(id: 'invalid')
will not.
-
-
github.com github.com
-
The main realization came when I figured out that the main_model was just another association. This means we can move a lot of logic to just that class and reason about it a lot better.
-
- Jan 2021
-
-
This syntax easily provides all the features of components, like let: bind: and on:. <svelte:fragment /> is just a component with a special name.
-
-
redfin.engineering redfin.engineering
-
Service Workers are the hot new thing in web APIs. They’re designed to be like the HTML5 Application Cache, but without being objectionable.
-
-
alistapart.com alistapart.com
- Dec 2020
-
thecodebarbarian.com thecodebarbarian.com
-
the best way to ensure you've handled all errors in your run() function is to use run().catch(). In other words, handle errors when calling the function as opposed to handling each individual error.
-
// The `.then(v => [null, v], err => [err, null])` pattern // lets you use array destructuring to get both the error and // the result
-
- Nov 2020
-
-
Can you image your favorite web app working offline? Well, Progressive Web Apps (PWA) are here. One of their main benefits is that Service Workers will allow you to continue loading your apps even when there’s no internet connection.
-
Service Workers are also helpful for offline caching and performance. You can write code to cache your application shell to work offline and populate its content using JavaScript.
-
-
laniewski.me laniewski.me
-
For example, your application should work offline, but it doesn’t mean that you must set-up a background queue or store your data in a persistent storage – a offline message (e.g. “You’re offline, check your network status.”) is enough.
-
-
stackoverflow.com stackoverflow.com
-
yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; }
-
If you were to check the return status of every single command, your script would look like this:
Illustrates how much boilerplate set -e saves you from.
Update: Oops, if you read a comment further below, you learn that:
Actually the idiomatic code without
set -e
would be justmake || exit $?
True that.
-
- Sep 2020
-
javascript.info javascript.info
-
The "invisible try..catch" around the executor automatically catches the error and turns it into rejected promise.
-
-
github.com github.com
-
Re Object.keys(undefined), I think I'm ok with that failing. AFAIK it would also fail in React
-
I just don't know if Svelte should handle it, since #each also fails for undefined iterators.
-
-
-
.catch(error => download_count = error) // check for error in template
-
- Aug 2020
-
english.stackexchange.com english.stackexchange.com
-
As a web designer, I hate that "log in" creates a visual space between the words. If you line up "Log In Register" - is that three links or two? This creates a Gestalt problem, meaning you have to really fiddle with spacing to get the word groupings right, without using pipe characters.
Sure, you can try to solve that problem by using a one-word alternative for any multi-word phrase, but that's not always possible: there isn't always a single word that can be used for every possible phrase you may have.
Adjusting the letter-spacing and margin between items in your list isn't that hard and would be better in the long run since it gives you a scalable, general solution.
"Log in" is the only correct way to spell the verb, and the only way to be consistent with 1000s of other phrasal verbs that are spelled with a space in them.
We don't need nor want an exception to the general rule just for "login" just because so many people have made that mistake.
-
- Jul 2020
-
code-examples.net code-examples.net
-
JSON parsing is always pain in ass. If the input is not as expected it throws an error and crashes what you are doing. You can use the following tiny function to safely parse your input. It always turns an object even if the input is not valid or is already an object which is better for most cases.
It would be nicer if the parse method provided an option to do it safely and always fall back to returning an object instead of raising exception if it couldn't parse the input.
-
-
osf.io osf.io
-
Andia, T., Mantilla, C., Rodriguez-Lesmes, P., Criado, L., Gomez, J. S., Ortiz, S., Quintero, A., Rincón, H., & Romero, S. (2020). Mentioning anosmia improves how community pharmacies handle phone call requests during the COVID-19 pandemic: An audit study in Colombia [Preprint]. SocArXiv. https://doi.org/10.31235/osf.io/s2z47
-
- May 2020
-
developer.mozilla.org developer.mozilla.orgPromise2
-
in the absence of an immediate need, it is simpler to leave out error handling until a final .catch() statement.
-
Handling a rejected promise too early has consequences further down the promise chain. Sometimes there is no choice, because an error must be handled immediately.
-
- Apr 2020
-
www.techopedia.com www.techopedia.com
-
A language that features polymorphism allows developers to program in the general rather than program in the specific. $(document).ready(function() { recordAdModuleData(2964, "impressions","Dictionary Ad"); });
-
- Mar 2020
-
stackoverflow.com stackoverflow.com
-
To be just a bit polemic, your first instinct was not to do that. And you probably wouldn't think of that in your unit tests either (the holy grail of dynamic langs). So someday it would blow up at runtime, and THEN you'd add that safeguard.
-
I want to raise errors with more context
-
As many would guess: ... catch StandardError => e raise $! ... raises the same error referenced by $!, the same as simply calling: ... catch StandardError => e raise ... but probably not for the reasons one might think. In this case, the call to raise is NOT just raising the object in $!...it raises the result of $!.exception(nil), which in this case happens to be $!.
-
-
ruby-doc.org ruby-doc.org
-
It is recommended that a library should have one subclass of StandardError or RuntimeError and have specific exception types inherit from it. This allows the user to rescue a generic exception type to catch all exceptions the library may raise even if future versions of the library add new exception subclasses.
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
matcher === exception or exception.cause && block[exception.cause]
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
The pattern below has become exceptionally useful for me (pun intended). It's clean, can be easily modularized, and the errors are expressive. Within my class I define new errors that inherit from StandardError, and I raise them with messages (for example, the object associated with the error).
-
-
github.com github.com
- Dec 2019
- Mar 2019
-
www.thedevelopersconference.com.br www.thedevelopersconference.com.br
-
Você consegue visualizar a saúde da sua aplicação?
Ainda que aqui os tópicos da certificação não cubram exatamente esse assunto, monitorar a saúde de um sistema e suas aplicações é missão do profissional DevOps. Atente para os tópicos:
701 Software Engineering 701.1 Modern Software Development (weight: 6)
e
705.2 Log Management and Analysis (weight: 4)
-
- May 2018
-
hypothes.is hypothes.is
-
hi there we have came up with the newly launched Procedural Query in PL sql with Oracle 12 c so please check this out For detailed Description on the Pl Sql from the scratch to advance level:-
-