goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Refactor ErrorObject and Error classes' initialization #849

Open st0012 opened 4 years ago

st0012 commented 4 years ago

Currently, we allow raising errors from vm with any given string, like

t.vm.InitErrorObject("ErrorWithoutAClass", ....)

This is a bad practice because any internal error should have a corresponding error class.

This PR fixes this by only accepting pre-defined error types (enum) when initializing error objects. It also checks every error type (int) has a corresponding name (string) during vm initialization, which saves us the work to visually sync the 2 lists manually.

codecov[bot] commented 4 years ago

Codecov Report

Merging #849 into master will increase coverage by 0.00%. The diff coverage is 93.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #849   +/-   ##
=======================================
  Coverage   81.02%   81.03%           
=======================================
  Files          54       54           
  Lines        7496     7498    +2     
=======================================
+ Hits         6074     6076    +2     
  Misses       1188     1188           
  Partials      234      234           
Impacted Files Coverage Δ
vm/issue_vm.go 0.00% <0.00%> (ø)
vm/class.go 86.35% <100.00%> (ø)
vm/error.go 72.72% <100.00%> (+1.75%) :arrow_up:
vm/thread.go 90.45% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 44f3a14...d2b2734. Read the comment docs.