Comments (5)
I tryed some, so report them.
For all of below codes, I modified util/exception.sh a little bit:
28 command_not_found_handle() {
+ 29 echo $@
30 # USE DEFAULT IFS IN CASE IT WAS CHANGED
31 local IFS=$' \t\n'
32
- change
throw
alias to pass $1 tocommand_not_found_handle
Purpose: To check whether $1 will be passed to command_not_found_handle
Result: the argunment was not passed as $1
Tried to check whether alias is the problem:
# modified code: in util/exception.sh
alias throw="__EXCEPTION_TYPE__=\${e:-Manually invoked} command_not_found_handle hoge"
# my script is the same one as above
# outputs
throw
✘ UNCAUGHT EXCEPTION: Undefined command (throw)
➦ Undefined command [oo-bootstrap.sh:84]
✘ System::SourcePath "${__oo__path}/${libPath}" "$@" || e="Cannot import $libPath" throw [oo-bootstrap.sh:84]
➦ System::ImportOne "$libPath" [oo-bootstrap.sh:96]
➦ System::Import [command_not_found_handle_test.sh:3]
✘ import file_not_exist [command_not_found_handle_test.sh:3]
⚡ Press [CTRL+C] to exit or [Return] to continue execution.
hoge
, which was pessed as
I have no idea what's happen here...omg
(I searched if there're other definitions for throw
and command_not_found_handle
,
but I couldn't find anymore than I know.)(searched by using git grep
)
- call
throw
manually from my script
Purpose: To check whether throw
works correctly in other cases
Result: It worked
It seems that throw
works fine for manually executing.
I tested to call throw
by myself in my test script:
import util/exception util/log util/tryCatch
e="hello. test" throw "this is just atest"
then outputs:
✘ UNCAUGHT EXCEPTION: hello. test (this is just atest)
e="➦ hello. test" throw "this is just atest" [command_not_found_handle_test.sh:9]
⚡ Press [CTRL+C] to exit or [Return] to continue execution.
⚙ Continuing...
3.1 call throw
from my function
Purpose: To check whether function do something bad
Result: It worked
Call throw
in my function
# my script
import util/exception util/log util/tryCatch
testfunc() {
e="hello. test" throw "this is just atest"
}
testfunc
#
# outputs
this is just atest
✘ UNCAUGHT EXCEPTION: hello. test (hoge)
e="hello. test" throw "➦ this is just atest" [command_not_found_handle_test.sh:13]
➦ testfunc [command_not_found_handle_test.sh:16]
⚡ Press [CTRL+C] to exit or [Return] to continue execution.
3.2 call throw
from my function. excecute the function using alias
Purpose: To check whether alias do something bad
Result: It worked
Using testfunc
in 3.1, but call it using alias
# my script
import util/exception util/log util/tryCatch
testfunc() {
e="hello. test" throw "this is just atest"
}
alias ali="testfunc"
ali
# outputs
this is just atest
✘ UNCAUGHT EXCEPTION: hello. test (this is just atest)
e="➦ hello. test" throw "this is just atest" [command_not_found_handle_test.sh:13]
alias ali="➦ testfunc" [command_not_found_handle_test.sh:16]
⚡ Press [CTRL+C] to exit or [Return] to continue execution.
⚙ Continuing...
from bash-oo-framework.
sorry, this is not a bug of this framework, probably.
I tried with a simple snipet which does not use oo- framework and got the same result.
As I'm away from my PC, I'll post the code later.
from bash-oo-framework.
Here's the code!!
#!/usr/bin/env bash
alias test_a="command_not_found_handle"
command_not_found_handle() {
echo $*
}
test_a # call function using alias
echo '----'
command_not_found_handle # call function directly
and here's outputs:
$?is0[bugfix/throw-puts-wrong-exception]
<X_X>:bash-oo-framework$ ./test_throw_bug.sh # the above code
test_a
----
$?is0[bugfix/throw-puts-wrong-exception]
from bash-oo-framework.
It seems like a bash bug: even when the alias throw
is declared at the very beginning, it seems unavailable within the body of the System::ImportOne
function.
We can think about a good solution when planning for #45.
from bash-oo-framework.
I sent a bug-report to bash by using bashbug.
I hope this will be fixed someday...
If I find good solution, I'll post it to #45
And... Should we close this issue?
from bash-oo-framework.
Related Issues (20)
- Is the project dead? HOT 3
- Sorry, a bit cheeky/impolite... HOT 2
- error handling with throw / command_not_found_handle HOT 3
- Unbound variables cause a crash when running examples with 'set -u' HOT 3
- Catch exception from Classes doesn't work HOT 7
- Inconsistent array assignments HOT 3
- Translating README into Japanese
- for people who want to use Bpkg to install this framework HOT 1
- example/trycatch.sh doesn't work as expected
- Make wiki page
- [Question] Does value of '__primitive_extension_fingerprint' have special meaning?
- update readme instructions for namedParameters
- util/exception.sh shows stack trace as expected but don't exit on Ctrl+C HOT 2
- False boolean not working HOT 1
- Referring this in Human example class doesn't work as described HOT 1
- Exception messages are invisible in light theme mode in Shell console.
- [Question] Is this project still alive? HOT 6
- [Discussion] Log API
- Using a variable for an Object name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bash-oo-framework.