Is あわやと思った an idiom? What is the meaning of あわや?


I've come across this sentence

> あわやと思ったその時

and I have looked around without success for a translation for あわや. Tangorin
simply says it's an adverb meaning 'almost on the verge of happening', but
gives no example sentences. What does it mean? Maybe the context is
necessary... the whole sentence is

> あわやと思ったその時洞から失敬してきた剣がオレを救ってくれた

So... the sword that was stolen from the cave save me... but what about the
time it happen?

Thank you very much.




あわや is an adverb to refer to a situation where one escapes a danger by a hair.
I don't think the word あわ is used in any other context today, so I assume it's
a word from long time ago that survived only in combination with や that adds
emotion (this use of や is apparently called
[感動詞](https://ja.wikipedia.org/wiki/%E6%84%9F%E5%8B%95%E8%A9%9E))

So from there hopefully you can understand that あわやと思ったその時 means "just when I
thought I'm in great danger", and you expect something that saved him from
that situation would follow.




あわや is an adverb to refer to a situation where one escapes a danger by a hair.
I don't think the word あわ is used in any other context today, so I assume it's
a word from long time ago that survived only in combination with や that adds
emotion (this use of や is apparently called
[感動詞](https://ja.wikipedia.org/wiki/%E6%84%9F%E5%8B%95%E8%A9%9E))

So from there hopefully you can understand that あわやと思ったその時 means "just when I
thought I'm in great danger", and you expect something that saved him from
that situation would follow.

