Skip to content

Commit 256b684

Browse files
committed
refactor: perform consistent error handling
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 98ab999 commit 256b684

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
2324
var resolve = require( '@stdlib/blas/base/layout-resolve-enum' );
2425
var format = require( '@stdlib/string/format' );
2526
var addon = require( './../src/addon.node' );
@@ -59,11 +60,22 @@ var addon = require( './../src/addon.node' );
5960
* // A => <Float64Array>[ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]
6061
*/
6162
function dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) {
62-
var ord = resolve( order );
63-
if ( ord === null ) {
63+
if ( !isLayout( order ) ) {
6464
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
6565
}
66-
addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA );
66+
if ( M < 0 ) {
67+
throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) );
68+
}
69+
if ( N < 0 ) {
70+
throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) );
71+
}
72+
if ( strideX === 0 ) {
73+
throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) );
74+
}
75+
if ( strideY === 0 ) {
76+
throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) );
77+
}
78+
addon( resolve( order ), M, N, alpha, x, strideX, y, strideY, A, LDA );
6779
return A;
6880
}
6981

0 commit comments

Comments
 (0)