Skip to content

Instantly share code, notes, and snippets.

@mattdee123
mattdee123 / errors.md
Last active February 20, 2019 03:50
Error Handling Should Support Custom Error Types

Overall, the proposal seems great. However, one of the things I love about go is that the error type is not special (other than the fact that it doesn't require importing). This proposal seems to special-case the error type, adding extra barriers to defining ones own error types.

As an example, I was building an interpreter, and I wanted all of my parser's error messages to have a file position (line/column number) on them. By defining a new type,

type PosError interface{
  error
  Pos() FilePos
}

and making all of my functions return it, the compiler is able to remind me where I need to add a file position, since if I don't, typechecking will fail.

## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
global counter
counter = 1
class myHandler(BaseHTTPRequestHandler):
def do_POST(self):
global counter
print "GOT POST"
print type(self.rfile)
g = open("tests/" + str(counter) + "test.jpg", "wb")
counter += 1
function s = tex(m)
s = '\bm ';
for r = 1:size(m,1)
for c =1:size(m,2)
delim = '&';
if (c == size(m,2))
delim = '';
end
s = [s, K.asStr(m(r,c)), delim];
end
[12:21:08] matt: ~/p2/build make
[ 4%] Building CXX object application/CMakeFiles/application.dir/application.cpp.o
In file included from /home/matt/p2/src/scene/scene.hpp:12:0,
from /home/matt/p2/src/application/application.hpp:12,
from /home/matt/p2/src/application/application.cpp:8:
/home/matt/p2/src/math/vector.hpp: In member function ‘const real_t& _462::Vector2::operator[](size_t) const’:
/home/matt/p2/src/math/vector.hpp:135:9: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
/home/matt/p2/src/math/vector.hpp: In member function ‘_462::real_t& _462::Vector2::operator[](size_t)’:
/home/matt/p2/src/math/vector.hpp:144:9: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
/home/matt/p2/src/math/vector.hpp: In member function ‘const real_t& _462::Vector3::operator[](size_t) const’:
@mattdee123
mattdee123 / gist:6152707
Created August 5, 2013 00:37
Working POM file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wiki-graph</groupId>
<artifactId>wiki-graph</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>