# (koans)   uninitialized constant TriangleError

**URL:** <https://discuss.rubyonrails.org/t/koans-uninitialized-constant-triangleerror/65212>\
**Category:** rubyonrails-talk\
**Created:** [September 22, 2012, 2:43pm UTC](https://discuss.rubyonrails.org/t/koans-uninitialized-constant-triangleerror/65212 "2012-09-22T14:43:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roelof\_Wobben](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Roelof\_Wobben](https://discuss.rubyonrails.org/u/Roelof_Wobben)\
**Post date:** [September 22, 2012, 2:43pm UTC](https://discuss.rubyonrails.org/t/koans-uninitialized-constant-triangleerror/65212/1 "2012-09-22T14:43:03Z")

</div>

Hello,

I have to make a exception part on triangles now.

The exercise looks like this : [/code]

# You need to write the triangle method in the file ‘triangle.rb’

require ‘triangle.rb’

class AboutTriangleProject2 \< EdgeCase::Koan

# The first assignment did not talk about how to handle errors.

# Let’s handle that part now.

def test\_illegal\_triangles\_throw\_exceptions assert\_raise(TriangleError) do triangle(0, 0, 0) end assert\_raise(TriangleError) do triangle(3, 4, -5) end assert\_raise(TriangleError) do triangle(1, 1, 3) end assert\_raise(TriangleError) do triangle(2, 4, 2) end # HINT: for tips, see [http://stackoverflow.com/questions/3834203/ruby-koan-151-raising-exceptions](http://stackoverflow.com/questions/3834203/ruby-koan-151-raising-exceptions) end end [/code]

So I looked at that page and come with this solution :

```ruby
def triangle(a, b, c)

  raise TriangleError, "length cannnot be 0 or lesser" if (a <= 0) or (b <= 0) or (c <= 0);
  raise TriangleError, "length does not mach Pyschotorogas" if (a * a + b * b != c * c);

  return :equilateral if ((a == b) and (b == c))
  return :isosceles if (((a == b) and (b != c)) or
                       ((a != b) and (b == c)) or
                       ((a == c) and (a != b)))
  return :scalene if ((a !=b) and (b != c))
end
```

But now I get a uninitialized constant TriangleError

What did I do wrong now ?

Roelof

---

<div class="post-metadata">

**Author:** ![Roelof\_Wobben](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Roelof\_Wobben](https://discuss.rubyonrails.org/u/Roelof_Wobben)\
**Post date:** [September 22, 2012, 5:09pm UTC](https://discuss.rubyonrails.org/t/koans-uninitialized-constant-triangleerror/65212/2 "2012-09-22T17:09:00Z")

</div>

Hello,

I found this solution :

# about\_triangle\_project.rb

# and

# about\_triangle\_project\_2.rb

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [September 23, 2012, 3:12pm UTC](https://discuss.rubyonrails.org/t/koans-uninitialized-constant-triangleerror/65212/3 "2012-09-23T15:12:43Z")

</div>

1) Very good. Now you should try to determine what "Ruby on Rails" is, and whether your questions have anything to do with Ruby on Rails.

2) Read a tutorial on ruby exception handling, or better yet buy the book "Beginning Ruby":

[http://beginningruby.org/](http://beginningruby.org/)

and read that before trying to do the koans. All you seem to be doing is copying other people's code, so what good does that do you?
